Update an API policy using management API's

Hi,

we can create a new policy using following endpoint :

https://api.enterprise.apigee.com/v1/organizations/org/apis/yourapi/revisions/1/policies

Is there a way we can update the created policy via management API?

Solved Solved
1 4 337
1 ACCEPTED SOLUTION

With little bit of experimentation, I was able to update the policy using below CURL command:

curl -X POST \ https://api.enterprise.apigee.com/v1/organizations/yourorg/apis/apiname/revisions/1/policies/policyn... -H 'Accept: application/json' \ -H 'Authorization: Basic yourauth' \ -H 'Content-Type: application/xml' \ -H 'Postman-Token: 078b4524-4311-44cf-9e8f-9cc98142978b' \ -H 'cache-control: no-cache' \ -d 'your assign message policy'

Unfortunately, Apigee has not document these API's any where.

View solution in original post

4 REPLIES 4

I dont think we have an PUT/Update API for that.

Did you look into Apigee maven plugin?

https://github.com/apigee/apigee-deploy-maven-plugin

--

Ok so you are using the policy name in the URI with the same POST method.

https://api.enterprise.apigee.com/v1/organizations/<org>-eval/apis/<api>/revisions/1/policies/<polic...;

Ideally speaking this should be a PUT method. Currently, the PUT method is giving 405 Method not allowed.

@Dino-at-Google can we add this as a new Mangement API? and what was the reason this Update API is not available?

With little bit of experimentation, I was able to update the policy using below CURL command:

curl -X POST \ https://api.enterprise.apigee.com/v1/organizations/yourorg/apis/apiname/revisions/1/policies/policyn... -H 'Accept: application/json' \ -H 'Authorization: Basic yourauth' \ -H 'Content-Type: application/xml' \ -H 'Postman-Token: 078b4524-4311-44cf-9e8f-9cc98142978b' \ -H 'cache-control: no-cache' \ -d 'your assign message policy'

Unfortunately, Apigee has not document these API's any where.

Can you mention, what changes have you done in the cURL?

Did you change the Policy name?

you first need to create the policy using the command on my first post.

only difference is that you need to change the URL to include policyname at the end.

My data is usual Assign message policy in XML. Intead of "your assign message policy", replace with below XML

<RaiseFault async="false" continueOnError="false" enabled="true" name="test">
    <DisplayName>test</DisplayName>
    <FaultResponse>
        <Set>
            <Headers>
                <Header name="Access-Control-Allow-Origin">*</Header>
                <Header name="Access-Control-Allow-Headers">origin, x-requested-with,accept,content-type, apikey, Authorization, hideOverlay</Header>
                <Header name="Access-Control-Max-Age">3628800</Header>
                <Header name="Access-Control-Allow-Methods">GET, PUT, POST, DELETE, OPTIONS</Header>
            </Headers>
            <Payload contentType="application/json">                           
              \{
                  "message":"Resource not found."                 
               } 
            </Payload>
            <StatusCode>404</StatusCode>
            <ReasonPhrase/>
        </Set>
    </FaultResponse>
    <IgnoreUnresolvedVariables>true</IgnoreUnresolvedVariables>
</RaiseFault>