I am referring to the following documentation to create an API proxy through Edge Management API calls, but I don't find the format of JSON that needs to be submitted.
https://apidocs.apigee.com/management/apis/post/organizations/%7Borg_name%7D/apis
The document has information about the name field in the JSON, not anything else.
Solved! Go to Solution.
Here's how you can do it. (Pseudo-code)
:org = yourorgname :env = test POST :mgmtserver/v1/o/:org/apis Authorization: :edge-auth content-type: application/xml <APIProxy name='TestBundle'/>
POST :mgmtserver/v1/o/:org/apis/TestBundle/revisions/1/policies Authorization: :edge-auth content-type: application/xml <RaiseFault name='RF-BadRequest'> <IgnoreUnresolvedVariables>true</IgnoreUnresolvedVariables> <FaultResponse> <Set> <Payload contentType='text/plain'>error</Payload> <StatusCode>400</StatusCode> <ReasonPhrase>Bad Request</ReasonPhrase> </Set> </FaultResponse> </RaiseFault>
POST :mgmtserver/v1/o/:org/apis/TestBundle/revisions/1/policies Authorization: :edge-auth content-type: application/xml <AssignMessage name='AM-Response'> <AssignTo createNew='false' transport='http' type='response'></AssignTo> <IgnoreUnresolvedVariables>false</IgnoreUnresolvedVariables> <Set> <Payload contentType='text/plain'>OK</Payload> <StatusCode>200</StatusCode> <ReasonPhrase>OK</ReasonPhrase> </Set> </AssignMessage>
POST :mgmtserver/v1/o/:org/apis/TestBundle/revisions/1/proxies Authorization: :edge-auth content-type: application/xml <ProxyEndpoint name="endpoint1"> <Description></Description> <HTTPProxyConnection> <BasePath>/apibasepath</BasePath> <VirtualHost>secure</VirtualHost> </HTTPProxyConnection> <FaultRules/> <PreFlow name="PreFlow"> <Request/> <Response/> </PreFlow> <PostFlow name="PostFlow"> <Request/> <Response/> </PostFlow> <Flows> <Flow name='t1'> <Request> </Request> <Response> <Step><Name>AM-Response</Name></Step> </Response> <Condition>proxy.pathsuffix MatchesPath "/t1" and request.verb = "GET"</Condition> </Flow> <Flow name='unknown request'> <Request> <Step><Name>RF-BadRequest</Name></Step> </Request> <Response> </Response> </Flow> </Flows> <RouteRule name='noroute'/> </ProxyEndpoint>
You can attach target endpoints similarly. POST to the /targets collection. There is also a /resources collection to which you can POST XSD, WSDL, JAR, nodejs, etc.
POST :mgmtserver/ v1/ o/ :org/ e/ :env/ apis/ TestBundle/ revisions/ 1/ deployments ? action=deploy Authorization: :edge-auth Content-type: application/ x-www-form-urlencoded
You can also use JSON to format these various entities. Change the content-type headers if you do that.
You just need to pass the json body as :
{ "name": "Test" }
This will create the simple structure and will not have any configuration. You need to add it manually.
Thanks,
Latheef D
Thank you for the information. So, all the configuration creation from Edge UI talks to the back end services directly? I was thinking that Edge UI makes internally some sort of API calls to the back ends.
It's not the Edge UI. When you create a proxy in Edge UI, It's first store in cassandra & deployed to message processor of Apigee. Apigee MP talks to backend. In Apigee Edge cloud you don't need to worry about the components. Because, It's saas. We manage it. You just focus on building APIs.
@Venkata Nandagiri , I suggest to learn basics of Apigee Edge first. You can use the 4 Minute videos.
Above API you have mentioned just creates a proxy. A proxy is a bundle of xml files and folders which contains route rules, policies like quota, conditional flows etc.
You generally don't use above API alone to create a proxy. You will use it along with API like https://apidocs.apigee.com/management/apis/post/organizations/%7Borg_name%7D/apis-0
I strongly suggest to get basics first using Apigee Edge UI even before you dive into Management APIs. You can use these 4 Minute Videos to gain Apigee Edge expertise quickly.
Thanks Anil. I will definitely go through all these videos to learn about Apigee Edge UI.
My original question was posted by referring to that API page only. It has the API spec to create a proxy with the name attribute. As you mentioned that a proxy is a bundle of xml files and folders which contains configuration/xml files and policy information.
I will rephrase my question as "Is it possible to create API proxy (bundle of xml/config and policies) without Edge UI?
@Venkata Nandagiri , Yes, You can create proxy bundle with out Edge UI using your favorite IDE. See article & video here.
As per the original question is there a way to create fully working proxies purely through the Management APIs not using uploads or IDEs? I want to use restful HTTP calls with a body of ideally JSON but XML is acceptable.
Not using uploads? I guess that means, not using a zipped bundle?
I don't believe I've ever done it with just JSON.
Normally I use the "import" API call, in which the caller sends up a ZIP file containing all the proxy endpoints, target endpoints, policies, and resources.
Each of the various entities I just mentioned also have API calls, so ... I suppose you could
But as I said, I haven't tried this.
Thanks @Dino-at-Google
Yes, I'd prefer not to use imports and uploads as that implies that I've already created the proxy somewhere else to then do the initial export. If i'm starting from a completely clean install and don't want to provide access to the UI I need to be able to create a proxy from scratch purely via API calls.
I've been looking at the docs for creating Proxies and Policies here:
https://apidocs.apigee.com/management/apis/post/organizations/%7Borg_name%7D/apis
But don't see any docs indicating how to add the proxy end points or target endpoints to the proxy created in the separate API call.
This doc shows how to create a target server but there's no info on making use of that in a proxy:
I also tried manually creating a proxy via the UI then retrieving it via the Get Proxy revision API hoping it would then contain everything I needed to subsequently alter the JSON and push it back in via the Create Proxy API but the returned payload from the Get didn't contain everything I had defined for the proxy, namely the endpoint parts in question above among other values.
Thanks,
Sam
I'll work up an example later today.
Thanks Dino.
In the meantime I've been trialling the zip bundle upload as well
Sam
See my full answer... just posted.
Here's how you can do it. (Pseudo-code)
:org = yourorgname :env = test POST :mgmtserver/v1/o/:org/apis Authorization: :edge-auth content-type: application/xml <APIProxy name='TestBundle'/>
POST :mgmtserver/v1/o/:org/apis/TestBundle/revisions/1/policies Authorization: :edge-auth content-type: application/xml <RaiseFault name='RF-BadRequest'> <IgnoreUnresolvedVariables>true</IgnoreUnresolvedVariables> <FaultResponse> <Set> <Payload contentType='text/plain'>error</Payload> <StatusCode>400</StatusCode> <ReasonPhrase>Bad Request</ReasonPhrase> </Set> </FaultResponse> </RaiseFault>
POST :mgmtserver/v1/o/:org/apis/TestBundle/revisions/1/policies Authorization: :edge-auth content-type: application/xml <AssignMessage name='AM-Response'> <AssignTo createNew='false' transport='http' type='response'></AssignTo> <IgnoreUnresolvedVariables>false</IgnoreUnresolvedVariables> <Set> <Payload contentType='text/plain'>OK</Payload> <StatusCode>200</StatusCode> <ReasonPhrase>OK</ReasonPhrase> </Set> </AssignMessage>
POST :mgmtserver/v1/o/:org/apis/TestBundle/revisions/1/proxies Authorization: :edge-auth content-type: application/xml <ProxyEndpoint name="endpoint1"> <Description></Description> <HTTPProxyConnection> <BasePath>/apibasepath</BasePath> <VirtualHost>secure</VirtualHost> </HTTPProxyConnection> <FaultRules/> <PreFlow name="PreFlow"> <Request/> <Response/> </PreFlow> <PostFlow name="PostFlow"> <Request/> <Response/> </PostFlow> <Flows> <Flow name='t1'> <Request> </Request> <Response> <Step><Name>AM-Response</Name></Step> </Response> <Condition>proxy.pathsuffix MatchesPath "/t1" and request.verb = "GET"</Condition> </Flow> <Flow name='unknown request'> <Request> <Step><Name>RF-BadRequest</Name></Step> </Request> <Response> </Response> </Flow> </Flows> <RouteRule name='noroute'/> </ProxyEndpoint>
You can attach target endpoints similarly. POST to the /targets collection. There is also a /resources collection to which you can POST XSD, WSDL, JAR, nodejs, etc.
POST :mgmtserver/ v1/ o/ :org/ e/ :env/ apis/ TestBundle/ revisions/ 1/ deployments ? action=deploy Authorization: :edge-auth Content-type: application/ x-www-form-urlencoded
You can also use JSON to format these various entities. Change the content-type headers if you do that.
I don't know why the darn "deploy" command isn't appearing. It's in my post . I've edited it 5 times to get it to appear. This is another version with some spaces injected into it . Remove the spaces to get the real command:
POST :mgmtserver/ v1/ o/ :org/ e/ :env/ apis/ TestBundle/ revisions/ 1/ deployments ? action=deploy Authorization: :edge-auth Content-type: application/ x-www-form-urlencoded
Frustrating that this forum is mis-formatting my code. Grrrr.
Hi @Dino-at-Google, Thanks for this great information. However I could not find a reference of those '/proxies' and '/targets' endpoints in management API documentation, Can you please point where it is documented? Are these not documented under https://apidocs.apigee.com/api-reference/content/introduction?
It's possible that these collections are not documented.
EDIT 2023 October 24: Also, these collections are not supported in Apigee X or hybrid. You cannot update individual policies or create endpoints, step by step, with different REST calls. The only way to get a proxy into Apigee X or hybrid is to import a bundle. REST API doc here. Or you can use the apigeecli tool like this:
apigeecli apis create bundle -f ./path/to/apiproxy --name name-of-my-api-proxy -o $ORG --token $TOKEN
Hi,
Would you able to mention the update api call for org/apis/TestBundle/revisions/1/proxies.
I have tried PUT, but it returns an error saying not supported.
If I try post again, it returns an error:
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<Error>
<Code>messaging.config.beans.ProxyEndpointAlreadyExists</Code>
<Message>A Proxy endpoint named default already exists</Message>
<Contexts/>
</Error>
Maybe you are using the wrong URL ? This works for me.
curl -i -n -H content-type:application/json \ --data-binary "@endpoint1-modified.json" \ -X PUT \ $mgmtserver/v1/o/$ORG/apis/$PROXY/revisions/$REVISION/proxies/$ENDPOINT
Note the endpoint must be included in the URL. In your case "default" .
ps: don't do this to a proxy revision that is currently deployed. Bad Things will happen.
EDIT: This won't work with Apigee X or hybrid!
Thanks. Having $ENDPOINT at the end as default worked.
Hi @dchiesa1
This blog is really helpful!
But is there any management api of proxy endpoint ,targetendpoint ,policy in apigee X?
I have created a Postman collection example of how to create a proxy, decorate it with policies (apikey, scrub headers), deploy, test and undeploy using the Management APIs.
Please read the collection documentation on how to run as it uses both global variables for Organization, Email and PWD plus a CSV for Apiname, Proxy Endpoint, Environment and Target to onboard APIs en mass.
The example will accomplish the following...
1. Create the new bare API Proxy
2. Add a policy (Scrub Headers) to the Proxy. The policy will be unattached to the flow.
3. Add a policy (apikey verification) to the Proxy. The policy will be unattached to the flow
4. Add the target endpoint (per variables) and add the policy from step 3 into the flow
5. Add the proxy endpoints and add the policy from step 2 into the flow.
6. Deploy the proxy
7. Test the proxy
8. Undeploy the proxy
9. Delete the proxy
Not a replacement for CI/CD but can get you off the ground fairly quickly.
Hope this helps.
i'm very interested in seeing these postman collections, but get a 403 when trying to access. can these be made available in this forum?
Me too. Bill, can you re-attach the zip? (Maybe something went wrong with the forum software)
The easier way of deploying api proxy would be by using a tool, which internally manages the API invocation/payload/authentication.
ADT has documentation of how to use the tool and deploy proxies.
https://github.com/ashishkpathak/adt