Passing response data into query string another API inCollections

Hi,
My Collection has 2 APIs, the response from first API should be passed into the query string of second API request. How can I achieve this, I added following to Post-response script of first API:

const data = pm.response.json().data; // get "data" property from response object

pm.collectionVariables.set('data', JSON.stringify(data)); // set as a collection var named 'data'

not sure how to get this data into my query string of my second API which goes: `{{TARGET_SITE}}/api/v1/tickets/{{data}}/section/completion`
  • Platform Details: Postman 11.18.0, MacOS Sonoma 14.6.1

The data variable in that URL is a path, not a query string which normally starts with ?key=value.

For example.

You can change the value to a variable.

To add a path variable, you just put a colon before the variable.

Which will then show up in the path variables section.

What is the problem. You are setting a collection variable called data. Is it not working?

You may need to call it something else other than data as that used to be a reserved word.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.