Trying to get a session value from a POST call

I am getting the following error TypeError: postman.getResponseHeader is not a function while trying to retrieve a session key from this value returned in a post response:

Location →http://partners.api.skyscanner.net/apiservices/pricing/uk2/v1.0/b5b906e9-164e-4f1d-b5ce-9085b8a3506d

Are postman.getResponseHeader and JSON.parse functions available in Pre-request script in most recent Postman version?

I created this question originally in https://stackoverflow.com/questions/57212234/trying-to-get-a-session-value-from-a-post-call-in-postman-typeerror-postman-ge

Kindly, do you see any strange thing in the uploaded screen shot below? I saw in several blogs people using the function I am trying to use. Am I using in wrong place or should I add some extra dependency to postman? I guess not.

Hey @jimis.drpc,

Thanks for your question :trophy:

That is the older syntax and you can find the new pm.* API way of getting those Response Headers here:

As it’s the Response Headers that you’re trying to access, those would be available after the request has been made, not before.

You would need to move that part of your script over to the Tests tab. It looks like the same solution was given over on Stackoverflow.

Hope that helps.

2 Likes

Thanks, now it is working.