Create KVM using management API

Hello,

I want to create a KVM using Kvm management api ,I made a proxy in that want to call management api using service callout policy to create kvm .

management api:-https://api.enterprise.apigee.com/v1/organizations/{org_name}/environments/{env_name}/keyvaluemaps

passing that value :-

{ "name" : "kvmcreate", "encrypted" : "true", "entry" : [ { "name" : "test1", "value" : "11" }, { "name" : "test2", "value" : "12" } ] }

Service callout:-

<ServiceCallout name="SC-Create_KVM">
  <DisplayName>SC-Create_KVM</DisplayName>
  <Properties/>
  <Request clearPayload="false" variable="myRequest"> <IgnoreUnresolvedVariables>false</IgnoreUnresolvedVariables>
  <Add>
    <Header name="Authorization">Basic MASKED==</Header>
  </Add>
  <set>
    <Payload contentType="application/json" variablePrefix="$" variableSuffix="#">$request.content#</Payload>
    <Verb>POST</Verb>
  </set>
  </Request>
  <Response>calloutResponse</Response>
  <HTTPTargetConnection>
    <URL>https://api.enterprise.apigee.com/v1/organizations/{-------------eval}/environments/test/keyvaluemaps</URL>
  </HTTPTargetConnection>
</ServiceCallout>

So any one suggest that how could do this.

Thanks

0 4 823
4 REPLIES 4

@himanshu sharma

Firstly, calling management APIs from an API proxy is not a recommended practice. Management APIs should be executed only by a user with admin privileges.

Secondly, creating a KVM and adding the initial entries is a one time setup activity. So what's the usecase to do it from within an API proxy?

You will be making the Apigee environment configuration vulnerable if you open up api endpoints through an api proxy to modify it.

Ideal way would be to maintain postman scripts or curl commands to do these activities.

I made a proxy in that want to call management api using service callout policy to create kvm .

Please observe these three rules for when you think you want to call management APIs from an API Proxy:

  1. Don't do this.
  2. Do not do this.
  3. Avoid this.

You described what you're trying, but not the problem you're experiencing.

Himanshu, you should change your password on Apigee immediately. In a previous version of this post, you posted your credentials.