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

  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

About this issue

  • Original URL
  • State: open
  • Created 7 years ago
  • Comments: 17 (4 by maintainers)

Most upvoted comments

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

@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

@snk20501 @LeonardoGonzales @zhak @borodaalex Could you try the following snippet out and let me know if it works for you?

pm.response.headers.one('my_header_name');

So the debate is … should we have a polymorphic function return signature for headers? i.e. return string for single and array for multiple. That may break many current use cases across Postman and Newman.

Or find a way to add another function that takes care of this / extra param to indicate allowing multi-value (and make all returns array when that param is set to true -> including for single value)?

So, what happens with query string duplication? @kamalaknn

Refer: https://github.com/postmanlabs/postman-app-support/issues/6143

@kunagpal I try following script but still get the same result. The POSTMan version is the latest v5.5.2. pm.response.headers.one('my_header_name');

@snk20501 Could you confirm that this still works correctly with v5.3.1 of the Postman app? I’ll dig deeper into the header fetch issue in the meantime. 😄