I’m running into a problem with newman when running one of my collections, and I can’t quite figure out where things are going wrong. I’ve seen the other threads mentioning issues when running stuff with newman, but I can’t find one that seems applicable to me.
In my script I grab the value of the Set-Cookie
header, and extract the bit I need. This string is then set as a global variable, {{tracking_code}}, which is used by the next test. When I run the test on the cli, this is what I see:
→ get shared lists
GET https://integration-api..../api/listing/v1/shared/FPTFMTV [200 OK, 488B, 337ms]
┌
│ 'correlation id = wishlist_3c956902-3818-42cf-b0c8-82f0c7e9f6ac'
└
1⠄ TypeError in test-script
→ list checkout
POST https://integration-api......./api/listing/v1/checkout [500 Internal Server Error, 473B, 221ms]
2. response code should be '204 No Content'
┌
│ '::: REQUEST DATA :::'
│ '{\n\t"token" : "{{tracking_code}}",\n\t"lineItems" : [\n\t\t{ \n\t\t\t"skuId" : "237397061",\n\t\t\t"quantity" : 1\n\t\t}\n\t]\n}'
I’m wondering why {{tracking_code}} isn’t being set for the subsequent request?
This is the body of the request where I’m re-using {{tracking_code}}:
{
"token" : "{{tracking_code}}",
"lineItems" : [
{
"skuId" : "{{skuID}}",
"quantity" : 1
}
]
}
And this is how I set it:
var header = pm.response.headers.get(`Set-Cookie`);
pm.globals.set(`tracking_code`, header.substring(8, 20));
Using Postman I can see everything looks happy:
I’m so stumped by this, any ideas appreciated.