Deploying an API Proxy on Apigee

45 minutes
  • 7 Learning Objectives

About this Hands-on Lab

When developing Apigee API proxies, you’re constantly making updates to the underlying code. Some changes are small, like changing the rate value on a quota policy. These modifications can be safely incorporated into the current revision with a simple save. Other alterations — like changing the name of an existing policy — are more substantial and require a new revision. In this lesson, we’ll trigger such an action and learn how to deploy the new revision properly so we can test and continue developing an API proxy.

Learning Objectives

Successfully complete this lab by achieving the following learning objectives:

Open the API Proxy
  1. On the Apigee dashboard page, click API Proxies.
  2. Select LA-Weather from the list of proxies.
Add a New Policy
  1. Click the DEVELOP tab.
  2. In the Navigator area, under Proxy Endpoints, select Preflow.
  3. In the Request flow, click + Step.
  4. In the Add Step dialog, scroll down to the MEDIATION section, and select the Extract Variables policy.
  5. Leave the Display Name and Name set to their default values, and click Add.
Customize the Policy
  1. Click the Extract Variables policy icon.
  2. Change <QueryParam name="name" /> to the following:
    &lt;QueryParam name="q">
          &lt;Pattern>{cityName}&lt;/Pattern>    
    &lt;/QueryParam>
  3. Click Save.
Execute a Trace Session
  1. Select the TRACE tab.
  2. In the URL field, add the following query parameters to the API proxy URI:
    ?q=brooklyn&appid=[YOUR_OPENWEATHERMAP_API_KEY]
    If you do not have a OpenWeatherMap API key, use fd4698c940c6d1da602a70ac34f0b147.
  3. Click Start Trace Session.
  4. Click Send.
  5. Note the 200 status returned by the API.
  6. In the Transaction Map, click the Extract Variables icon, and review the apigee.cityName property value.
  7. Click Stop Trace Session.
  8. Select the URL, and copy it to your clipboard.
Modify the API Proxy
  1. Select the DEVELOP tab.
  2. Click the Extract Variables policy icon.
  3. In the code, locate the <ExtractVariables> element, and change the name attribute to ExtractCityName.
  4. Change the <DisplayName> value to Extract City Name.
  5. Click Save.
  6. When the dialog appears noting that you need to save these changes as a new revision, click Save as New Revision.
Test the Modification
  1. Select the TRACE tab.
  2. Note that the URL is unavailable.
  3. Paste the copied URL into the field.
  4. Click Start Trace Session.
  5. Note that you cannot start a trace and that in the Deployment to Trace select list, only Revision 1 is available.
Deploy the New Revision
  1. Return to the DEVELOP tab.
  2. Make sure that Revision 2 is selected in the upper left corner of the screen.
  3. From the Deployment dropdown menu, select Test.
  4. In the confirmation dialog, click Deploy.
  5. After the deployment is complete, return to the TRACE tab.
  6. Paste the copied URL into the field.
  7. Click Start Trace Session.
  8. Change the town parameter from brooklyn to chicago.
  9. Click Send.
  10. Note the 200 status returned by the API.
  11. Click the Extract Variables policy icon, and review the apigee.cityName property value.

Additional Resources

You've made a significant change to your existing API, which resulted in a new revision being created. You run a trace but do not see the change reflected in the results. You realize that you need to deploy the current revision. After deploying the revision to the test environment, you re-run the trace, and your API updates are displayed.

You’ll need to complete the following steps to accomplish your task:

  1. Make a significant change to your API.
  2. Execute a trace.
  3. Deploy the current revision to the test environment.
  4. Execute the trace again.

Please note: There are several prerequisites for this hands-on lab:

  1. You must have an Apigee account.
  2. You must have completed the following hands-on labs: Creating an Apigee API Proxy and Testing an API Proxy.
  3. Optionally, you should have registered for an API key with OpenWeathermap.org.

What are Hands-on Labs

Hands-on Labs are real environments created by industry experts to help you learn. These environments help you gain knowledge and experience, practice without compromising your system, test without risk, destroy without fear, and let you learn from your mistakes. Hands-on Labs: practice your skills before delivering in the real world.

Sign In
Welcome Back!

Psst…this one if you’ve been moved to ACG!

Get Started
Who’s going to be learning?