postman.getResponseHeader cant's get full content of Header value
See original GitHub issue- Newman Version (can be found via
newman -v
): 3.8.3 - OS details (type, version, and architecture): Ubuntu 16.04.02 64bit LTS server
- Are you using Newman as a library, or via the CLI? CLI
- Did you encounter this recently, or has this bug always been there: always been there
Steps to reproduce the problem:
- use postman.getResponseHeader in test collection to get header value.
- 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:
- Created 6 years ago
- Comments:17 (4 by maintainers)
Hi guys, I have same issue,
response has following headers (pretty view):
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
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