Compare two responses

Number of APIs: 1

This is an answer to the following question on the Qodex Community Forum:
[

This collection shows how you can compare the responses of two different requests to see if they're identical. In this case, we're making the same request and expecting the same exact response. In Request A, we stringify the response and then save the response as a collection variable in the Tests tab.

In the second request, we retrieve the response we just saved and access it in the Qodex sandbox using the pm.collectionVariables.get method. Next, we use a a pm assertion to see if the response from the first request is equal to the stringified version of the second response.

  1. Request B GET https://pokeapi.co/api/v2/pokemon/ditto/