Pez
Pez

Reputation: 1101

How to use SessionID using PostMan Rest client

Getting "SessionId" from response of user logged in session using POSTMAN REST client.

How to use the sessionId for other API calls of GET request?

Upvotes: 3

Views: 7303

Answers (1)

Lee Chant
Lee Chant

Reputation: 103

Making a few assumptions about your data structure, store it as a variable:

//parse the response body as JSON 
var data = JSON.parse(responseBody);

//create a global variable that can be reused in another call
postman.setGlobalVariable("sessionId", data.SessionId")

To use in a call to another endpoint:

http://www.example.com/{{sessionId}}

Upvotes: 3

Related Questions