Complete the code to set the environment variable with the response value.
pm.environment.set('userId', [1]);
The correct way to get a value from the JSON response is using pm.response.json().id. This sets the environment variable userId for chaining.
Complete the code to use the environment variable in the next request URL.
pm.request.url = `https://api.example.com/users/$[1]`;To use the stored variable in the request URL, use pm.environment.get('userId') which retrieves the value set earlier.
Fix the error in the test script to correctly check the response status code.
pm.test('Status code is 200', function () { pm.response.to.have.status([1]); });
The status code should be a number, so 200 without quotes is correct. Using quotes makes it a string, causing the test to fail.
Fill both blanks to extract 'token' from response and set it as a global variable.
const token = pm.response.json().[1]; pm.globals.set('[2]', token);
The response JSON property is 'token', and the global variable name to set is 'authToken'. This allows chaining with a global token.
Fill all three blanks to create a test that checks if the response JSON has a 'success' property set to true.
pm.test('Response success is true', function () { const jsonData = pm.response.[1](); pm.expect(jsonData.[2]).to.eql([3]); });
Use pm.response.json() to parse JSON, check the 'success' property, and expect it to equal true (boolean).