Hello ! May be someone can help me)
What i want:
- I have a collection variable on
POST/ request
{ "Amount": .....,
"Id": ........,
"customerId": "{{$randomUUID}}",
}
- To cath the value of this variable to use it in the next POST request i need to log it in console so i have used script:
const requestJson = pm.request.toJSON();
pm.collectionVariables.set('aRequestAsJson', JSON.stringify(requestJson));
const x = JSON.parse(pm.collectionVariables.get('aRequestAsJson'));
console.log(JSON.parse(x.body.raw).customerId);
and the UUID that were used in request body is successfully logged in my console
and presented as :
POST https://............
"fb8c4dd4-5e31-4620-b94f-849dffb0d2fd"
But how can i set that console data(i mean fb8c4dd4-5e31-4620-b94f-849dffb0d2fd
) as a collection variable to use in my next POST/ request
?
I trying something like that:
const requestJson = pm.request.toJSON();
pm.collectionVariables.set('aRequestAsJson', JSON.stringify(requestJson));
const x = JSON.parse(pm.collectionVariables.get('aRequestAsJson'));
console.log(JSON.parse(x.body.raw).customerId);
pm.collectionVariables.set("UuidForTheNextPostRequest", (x.body.raw).customerId);
but it doesnt works(