question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

postman.getResponseHeader cant's get full content of Header value

See original GitHub issue
  1. Newman Version (can be found via newman -v): 3.8.3
  2. OS details (type, version, and architecture): Ubuntu 16.04.02 64bit LTS server
  3. Are you using Newman as a library, or via the CLI? CLI
  4. Did you encounter this recently, or has this bug always been there: always been there

Steps to reproduce the problem:

  1. use postman.getResponseHeader in test collection to get header value.
  2. If the header value returned from server is as following. The value postman.getResponseHeader get is not full content. It get “</redfish/v1/UpdateService>; path=/UpdateService” only.

<http://redfish.dmtf.org/schemas/v1/ServiceRoot.v1_1_1.json>; rel=describedby, </redfish/v1/TaskService>; path=/Tasks, </redfish/v1/Chassis>; path=/Chassis, </redfish/v1/SessionService/Sessions>; path=/Links/Sessions, </redfish/v1/Managers>; path=/Managers, </redfish/v1/EventService>; path=/EventService, </redfish/v1/JsonSchemas>; path=/JsonSchemas, </redfish/v1/Systems>; path=/Systems, </redfish/v1/Registries>; path=/Registries, </redfish/v1/configurations>; path=/Oem/Ami/Configurations, </redfish/v1/SessionService>; path=/SessionService, </redfish/v1/AccountService>; path=/AccountService, </redfish/v1/UpdateService>; path=/UpdateService

Please help to look into this issue Note. This issue can’t reproduce in POSTMAN

Issue Analytics

  • State:open
  • Created 6 years ago
  • Comments:17 (4 by maintainers)

github_iconTop GitHub Comments

10reactions
ekarpiecommented, Jan 24, 2018

Hi guys, I have same issue,

  • Ubuntu 16.04
  • standalone Postman 5.5.0

response has following headers (pretty view):

Server →xxxxxxxx-xxxxx
Set-Cookie →APSCOOKIE_9539865665021864916="0%260"; path=/; expires=Tue, 06-Feb-1968 18:34:11 GMT
Set-Cookie →VDOM_9539865665021864916="0%260"; path=/; expires=Tue, 06-Feb-1968 18:34:11 GMT
Set-Cookie →log_filters="0%260"; path=/log/; expires=Tue, 06-Feb-1968 18:34:11 GMT
Set-Cookie →log_type="0%260"; path=/log/; expires=Tue, 06-Feb-1968 18:34:11 GMT
Set-Cookie →CENTRAL_MGMT_OVERRIDE_9539865665021864916="0%260"; path=/; expires=Tue, 06-Feb-1968 18:34:11 GMT
Set-Cookie →EDIT_HISTORY_9539865665021864916="0%260"; path=/; expires=Tue, 06-Feb-1968 18:34:11 GMT
Set-Cookie →FILE_DOWNLOADING_9539865665021864916="0%260"; path=/; expires=Tue, 06-Feb-1968 18:34:11 GMT
Set-Cookie →csrftoken_9539865665021864916="0%260"; path=/; expires=Tue, 06-Feb-1968 18:34:11 GMT
Set-Cookie →ccsrftoken_9539865665021864916="0%260"; path=/; expires=Tue, 06-Feb-1968 18:34:11 GMT
Set-Cookie →ccsrftoken="0%260"; path=/; expires=Tue, 06-Feb-1968 18:34:11 GMT

for single value header all looks good: postman.getResponseHeader(‘server’) ----> “xxxxxxxx-xxxxx”

but for multi-value header like set-cookie we are receiving last element of array, at index 9: postman.getResponseHeader(‘Set-Cookie’) ----> “ccsrftoken=“0%260”; path=/; expires=Tue, 06-Feb-1968 18:30:59 GMT”

also

pm.response.headers.one(‘Set-Cookie’).value;----> “ccsrftoken=“0%260”; path=/; expires=Tue, 06-Feb-1968 19:36:57 GMT”

So the clue is that getResponseHeader works incorrect and return last value of multivalue header This function should return an array of all values for given header name

My workaround for a moment is to use

// print all Set-Cookie header values
pm.response.headers.all()
    .filter(headerObj => { return headerObj.key == "Set-Cookie";})
    .forEach(headerObj => {
        console.log(headerObj.key +": "+headerObj.value)
    })

BR, Karol

3reactions
LeonardoGonzalescommented, Feb 22, 2018

@kdp88 did you try it: var pageHeader = JSON.parse(postman.getResponseHeader(‘X-Pagination’) ); console.log(pageHeader.TotalCount);

thank @ekarpie, your “work around” worked very well for me

Best Regards

Leo

Read more comments on GitHub >

github_iconTop Results From Across the Web

Saving a Postman header value into a variable throughout ...
This is how you can do this. If Refresh_token is the header value postman.setGlobalVariable("refresh_token",postman.getResponseHeader("Refresh_token") );.
Read more >
Unable to read header value for a request that is sent in Pre-req
Hey, I need to get the value of one of the attribute in response header. The request is sent using the script in...
Read more >
Console Response Header Value, How to Retrieve?
I hope I am making sense. It looks like that original request is redirected (302 status) to a different URL which contains the...
Read more >
Access Response Headers with Postman Tests
Hi, Is there a way to access the Response Headers with a Postman test? ... log the Server and Content-Type values that are...
Read more >
Receiving responses | Postman Learning Center
If you receive a response with a different Content-Type header, ... A cookie's entry includes its name, value, the associated domain and ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found