Get hands-on experience with 20+ free Google Cloud products and $300 in free credit for new customers.

Mocking Service Callouts to another Apigee proxy

I have this longstanding issue, which I raised in one of the mad_in_api Q&As in December 2024, about how to test API proxies that have Service Callouts in their flow. This is a common flow that we have:

  1. Our Apigee instance receives a message and the corresponding proxy flow starts;
  2. As part of that flow, we need to get data from an external system, which we do via a Service Callout (SC) to another proxy. Once we get the response from the SC, the data is used in our flow and the process continues until a target system is called.

As part of developing our proxies, we use Javascript testing libraries to call our proxy (most of the time running Apigee in the emulator, but also in the cloud after deployment) and validate the responses' status codes, payloads, etc. We usually have a flag that prevents Apigee from calling the target system, and instead return the message that would have been sent to the latter.

This works fine for proxies that do not use service callouts, but fails (or forces us to use test cases that actually exist in a target system) when a proxy has a SC, since we get 500s back from the SC.

In the mad_in_api Q&A, @tylerayers presented us his solution using a mock proxy. It seems this could work for my team, but we would like to get more details on how to implement this.

Hope this will be useful for others as well!

1 2 264
2 REPLIES 2