Complete the code to insert the base URL variable in the request URL.
pm.sendRequest(`$[1]/users`, function (err, res) { pm.expect(err).to.be.null; pm.expect(res).to.have.property('code', 200); });
The base URL is stored as an environment variable. Use pm.environment.get('baseUrl') to retrieve it dynamically.
Complete the code to build a dynamic URL with a user ID path parameter.
const userId = pm.environment.get('userId'); const url = `$[1]/users/${userId}`; pm.sendRequest(url, function (err, res) { pm.expect(res).to.have.property('code', 200); });
To build the full URL, get the base URL from environment variables using pm.environment.get('baseUrl').
Fix the error in the code to correctly append query parameters to the URL.
const baseUrl = pm.environment.get('baseUrl'); const params = new URLSearchParams(); params.append('status', 'active'); const url = baseUrl + '/users?[1]'; pm.sendRequest(url, function (err, res) { pm.expect(res).to.have.property('code', 200); });
Use params.toString() to convert the URLSearchParams object to a query string.
Fill both blanks to build a URL with multiple query parameters dynamically.
const baseUrl = pm.environment.get('baseUrl'); const params = new URLSearchParams(); params.append('status', 'active'); params.append('role', [1]); const url = baseUrl + '/users?[2]'; pm.sendRequest(url, function (err, res) { pm.expect(res).to.have.property('code', 200); });
Use a string like 'admin' for the role parameter and convert params to string for the URL.
Fill all three blanks to build a dynamic URL with path and query parameters.
const baseUrl = pm.environment.get([1]); const userId = pm.environment.get('userId'); const params = new URLSearchParams(); params.append('active', [2]); const url = `${baseUrl}/users/$[3]?${params.toString()}`; pm.sendRequest(url, function (err, res) { pm.expect(res).to.have.property('code', 200); });
Get the base URL from environment variable 'baseUrl', use string 'true' for active, and use the userId variable for the path.