Trying to figure out why I cannot get this to work? Also, console does not give much of a result.
Scenario:
- Making the POST request to get the response with TOKEN
- Save the response token to collection variable (as the collection file will be used for importing to another testing solution in the cloud)
- Using that collection variable to log out from the session
So, I need to be able to store this as a collection variable and use that token when logging out from the session/DELETE the API admin session.
Error in the console:
There was an error in evaluating the test script: JSONError: Unexpected token 'o' at 1:2 [object Object] ^
Tests:
var response = pm.response.json()
var jsonData = JSON.parse(response)
pm.collectionVariables.set("token", jsonData.response.token);
Response body:
{
"response": {
"token": "***"
},
"messages": [
{
"code": "0",
"text": "OK"
}
]
}
var jsonData = JSON.parse(response)
as the first line is parsed already. Then update the reference to the value to the correct variable name. – Mummery