Skip to main content

Testing an Apigee API Proxy

Hands-On Lab

 

Photo of Joseph Lowery

Joseph Lowery

Google Cloud Training Architect II in Content

Length

00:45:00

Difficulty

Beginner

Developing an API proxy is similar to developing any other kind of software in that testing is required throughout its lifecycle. As you add policies or otherwise change the proxy code, you always have to ensure that you're getting the desired results. Apigee has a robust mechanism that shows you what's happening every step of the way: Trace, Apigee's built-in visual debugger. In this hands-on lab, we'll run a previously built API proxy through its paces, and we'll examine the data revealed in order to troubleshoot an issue.

What are Hands-On Labs?

Hands-On Labs are scenario-based learning environments where learners can practice without consequences. Don't compromise a system or waste money on expensive downloads. Practice real-world skills without the real-world risk, no assembly required.

Testing an Apigee API Proxy

Introduction

Developing an API proxy is similar to developing any other kind of software in that testing is required throughout its lifecycle. As you add policies or otherwise change the proxy code, you always have to ensure that you're getting the desired results. Apigee has a robust mechanism that shows you what's happening every step of the way: Trace, Apigee's built-in visual debugger. In this hands-on lab, we'll run a previously built API proxy through its paces, and we'll examine the data that is revealed in order to troubleshoot an issue.

Connecting to the Lab

  1. Navigate to https://cloud.google.com/apigee.
  2. Click the Try it free button.
  3. Create a free Apigee account.

Open the API Proxy

  1. On the Apigee dashboard page, click API Proxies.
  2. Select the LA-Weather proxy from the list.

Execute a Trace Session

  1. Click the TRACE tab.
  2. In the URL field, add the following query parameters to API proxy URI:
    ?q=london,uk&appid=[YOUR_OPENWEATHERMAP_API_KEY]

    If you do not have an OpenWeatherMap API key, use fd4698c940c6d1da602a70ac34f0b147.

  3. Click Start Trace Session.
  4. Click Send.

Debug the Results

  1. Note the 404 error status returned by the API.
  2. Under Transaction Map, select the various icons and review the output in the Phase Details section.
  3. Click the diamond-shaped Condition icon.
  4. Note the properties of the condition where the ExpressionResult is false.
  5. Click Stop Trace Session.
  6. In the URL, add /weather before the question mark for the query parameters.
  7. Click Start Trace Session.
  8. Click Send.
  9. Note the properties of the Condition and the output.
  10. Select the DEVELOP tab.
  11. Under Target Endpoints in the left navigation bar, select default.
  12. In the Code section, change the HTTPTargetConnection URL to: https://api.openweathermap.org/data/2.5/weather.
  13. Click Save.

Test the Modification

  1. Select the TRACE tab.
  2. If it exists, remove the previously inserted /weather from the URL.
  3. Click Start Trace Session.
  4. Click Send.
  5. Note the 200 status under Transactions and the JSON response in the Response Content section of Phase Details.
  6. Click Stop Trace Session.

Conclusion

Congratulations — you've successfully completed this hands-on lab!