My question:
My goal is to trigger a POST request for TokenRefresh and get the RefreshedToken Info from the request response and store it in a Collection variable.
Each request should then be able to use the updated Collection variable for its authentification.
When I send a request in the Collection, the Auth POST request is correctly sent, but something is wrong in my setting the Collection variable:
“TypeError: Cannot read properties of undefined (reading ‘json’)”
There was an error in evaluating the Pre-request Script:Error: Cannot read properties of undefined (reading ‘json’)
thanks for your detailed help!
I pasted your code into the Collection Pre-Script and updated my parameters and saved the changes.
When I POST a request in the collection, no error is generated, status 200.
But I can see that the Collection Variable CollRefToken is not being updated.
Does the Cookie play a role here? Generally, I want to use the refreshed Token in the Collection Variable CollRefTokenDev for every request, and not some value stored in a cookie.
CURL of request:
curl --location --request POST 'URL' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer eyJhbGcXXXXXX' \
--header 'Cookie: 5cfd47a23da9b9e1c98a84d0986d03c4=bb651d69ae861b858c8e7b91f7b51002' \
--data-raw '{
"$type": "BLA",
"Message": "Some Message expected to be received and processed by the system",
"MessageType": "BLA"
}'
I think this is related to my other post, where there is a Collection using new environment with Cookie (no value update) in comparison with a Collection using an old environment without cookie (value is being updated):