How to: manually zip up an API Proxy bundle into something that can be imported to Apigee Edge

Have you ever wanted to download an API proxy bundle from Apigee Edge, then unpack the zip file, and then modify one or two things, before zipping it up and uploading it (importing it) again?

Many customers use automated CI/CD pipelines to deploy their proxies into Apigee. But during development you may not yet have a CI/CD system set up. You may just be trying things out. Exploring.

In that case it would be nice to be able to do things "manually". Here's how.

First, obtain a zipped bundle. An easy way to do this is to export one from Edge. But you can also find zipped API Proxy bundles attached to articles or answers here on the Apigee community.

Then, unzip it. This should produce a directory tree like the following:

 apiproxy/ 
 apiproxy/oauth2-cc.xml 
 apiproxy/policies/ 
 apiproxy/policies/AM-CleanResponseHeaders.xml 
 apiproxy/policies/JS-GroomTokenResponse.xml 
 apiproxy/policies/OAuthV2-GenerateAccessToken-CC.xml 
 apiproxy/policies/RF-InvalidGrantType.xml 
 apiproxy/policies/RF-UnknownRequest.xml 
 apiproxy/proxies/ 
 apiproxy/proxies/default.xml 
 apiproxy/resources/ 
 apiproxy/resources/jsc/ 
 apiproxy/resources/jsc/dateFormat.js 
 apiproxy/resources/jsc/groomTokenResponse.js 
 apiproxy/resources/jsc/maybeFormatFault.js 

You can then go and edit any of those files, modify the basepath, and so on.

After you're finished, you will want to re-zip that directory tree. On Mac OSX, it is as simple as this:

$ zip -r oauth2-cc.zip apiproxy 
  adding: apiproxy/ (stored 0%)
  adding: apiproxy/oauth2-cc.xml (deflated 45%)
  adding: apiproxy/policies/ (stored 0%)
  adding: apiproxy/policies/AM-CleanResponseHeaders.xml (deflated 60%)
  adding: apiproxy/policies/JS-GroomTokenResponse.xml (deflated 31%)
  adding: apiproxy/policies/OAuthV2-GenerateAccessToken-CC.xml (deflated 62%)
  adding: apiproxy/policies/RF-InvalidGrantType.xml (deflated 44%)
  adding: apiproxy/policies/RF-UnknownRequest.xml (deflated 43%)
  adding: apiproxy/proxies/ (stored 0%)
  adding: apiproxy/proxies/default.xml (deflated 58%)
  adding: apiproxy/proxies/default.xml~ (deflated 68%)
  adding: apiproxy/resources/ (stored 0%)
  adding: apiproxy/resources/jsc/ (stored 0%)
  adding: apiproxy/resources/jsc/dateFormat.js (deflated 76%)
  adding: apiproxy/resources/jsc/groomTokenResponse.js (deflated 61%)
  adding: apiproxy/resources/jsc/maybeFormatFault.js (deflated 47%)
 

The result is a zip file that contains the API Proxy bundle, including all the proxy endpoints, the target endpoints, the policy definitions, and so on.

You can then import this with the Edge UI or the Edge API. Via the UI, just navigate to the Proxies list and click "+ API Proxy", and select "Existing Proxy bundle".

Via the API, you can do this:

  curl -i -n -X POST \
    "${mgmtserver}/v1/o/$org/apis?action=import&name=$proxyname" \
    -T $zipname -H "Content-Type: application/octet-stream"

(Check out this other article for a recommendation on the use of the -n option with curl.)

If you use the powershell module for Apigee Edge, then it looks like this:

Import-EdgeApi -Name oauth2-cc -Source oauth2-cc.zip

But... please note that with Powershell, the module itself will zip up the directory for you. So you could also do this:

Import-EdgeApi -Name oauth2-cc -Source c:\my\directory
Comments

And if you are using the maven deploy plugin, you can just run (assuming the pom.xml is in the same directory as apiproxy folder)

mvn apigee-enterprise:configure -P{profile}
tdavid99
Participant I

This NEVER works for me. I always receive an error like this:

dchiesa1
Staff

Hi Terry, I can't see the error you posted (sorry).

How can I help you? What specific problem are you having?

Version history
Last update:
‎05-31-2017 01:37 PM
Updated by: