Hi Folks!
I’m new to Postman and I have no sweet clue about coding. The only thing I kind of know is Excel VBA
I was following along with a previous question posted in 2018 (linked below) about how to store a JSON in a variable. I was able to get it to work but I don’t know how to clean up the response.
Note that the variable I’m trying to save is the Connection ID so it changes every time, so I’ve set the pre-request to clear the variable before the main call.
Thanks in advance!!!
Pre-Request
pm.collectionVariables.clear(“connectionID”)
Body
POST: https://stuff.com/(site share name)/ws/JSONBridge.cfm
{
“arguments”:{
“apiKey”:“1234”,
“logoutCurrentWebConnection”:false
},
“methodName”:“connectWithApiKey”,
“serviceName”:“ConnectionService”
}
Result
{
“result”:“(site share name)-(unique session ID)”
}
Post-Response
let response = pm.response.json(),
connectionID = JSON.stringify(response);
pm.collectionVariables.set(“connectionID”, connectionID);
The saved variable then looks like this
connectionID= “result”:“(site share name)-(unique session ID)”
when I really need it to be this
connectionID= (site share name)-(unique session ID)
How to store a JSON in a variable and use it in the request body?