Getting response into collection variable and putting it into another request with some values changed

I have a scenario where need to get response from one https request and put it into another, The catch is that while using this response into another http request I need to the name of one key value which I am getting from the previous response.

“Data”: [
“UID”: “Delta2”,
“ID”: “8”,
“Sequence”: 1}]}
This is the format of the data is something like what we are getting in response and requirement is to change the “Data” variable to “MetaData” while sending the request

responseJson = JSON.parse(responseBody);
for (var i = 0; i < responseJson.quote.length; i++)
var counter = responseJson.quote[i];
postman.collectionVariables(“responseBody”, counter);
Above is what I have tried

If you just want to change the key name, then you need copy the key, and delete the original.

There isn’t a rename function (unless you build your own JavaScript function).

Data in your response is a key. The array is the value.

let response = pm.response.json(); // JSON.parse(responseBody) is the old method.

response["MetaData"] = response["Data"]; // copy key
delete response["Data"]; // delete old key


Not sure what you are doing with that loop or how its relevant to your initial question. As “quote” doesn’t seem to be an element in your response. If quote did exist (as an array) then the collection variable would have just had the last element in the array as it would be overwritten each time within the loop.

Can you please use the pre-formatted text option in the editor when posting code or JSON examples, as it will stop all of the code being aligned to the left.