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?