Setting response body values as variables

94 Views Asked by At
  1. For the purpose of executing a number of scenarios. In the POSTMAN service, you need to perform certain queries. After receiving a response from the end server. For each request, in the body of the response, its own unique ID will be formed. Which is necessary in the future:
  2. Fix. That is, in some way to remember for the purpose of further references to it.
  3. Use the unique ID received (in the response body) for subsequent requests.

Example request:

POST {{base_url}}prospectivesales/create/v4

Response body:

{"ProspectiveSaleId":"018***e3-c**6-4**4-9**4-476f*****b14","PartnerCode":"b***0","Additions":[]}

Since the data in the "ProspectiveSaleId" variable is unique. And in each of the bodies, responses to the request will be formed, just as uniquely.

Example follow-up request:

GET {{base_url}}prospectivesales/{{prospectiveSale_Id}}/canedit

Server response and corresponding error:

{"errors":[{"message":"The value '\"ProspectiveSaleId\"' is not valid."}]}

or

POST {{base_url}}prospectivesales/{{prospectiveSale_Id}}/postpone

Server response and corresponding error: similar,

{"errors":[{"message":"The value '\"ProspectiveSaleId\"' is not valid."}]}

Environment variables are set in the following format:

[enter image description here](https://i.stack.imgur.com/ES4VH.png)

Please help me create the correct algorithm for subsequent requests using the body of the previous response to the request.

  1. There is an intermediate solution to the issue. However, the server also gives an error. The line for the TEST tab looks like this:
pm.globals.set('prospectiveSale_Id',
pm.response.json().prospectiveSaleId);

in the Test tab, as shown in the screenshot:

[screenshorts1][1]

After that I checked the environment of the variable. And the values appeared there as indicated in the screenshot:

[screenshorts2][2]

One of my subsequent requests received the following response, in the screenshot:

[screenshorts3][3]

and in the console:

Response Body

{"errors":[{"message":"The value 'null' is not valid."}]}
0

There are 0 best solutions below