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 →

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

I created this question originally in

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.


Thanks, now it is working.