Complete the code to send a GET request using Postman.
pm.sendRequest({ method: '[1]', url: 'https://api.example.com/data' }, function (err, res) { console.log(res.json()); });The GET method is used to retrieve data from the API. Postman uses this method to send a request and get a response.
Complete the code to check the status code in a response using REST-assured (Java).
given().when().get("/users").then().statusCode([1]);
Status code 200 means the request was successful. REST-assured uses statusCode() to verify this.
Fix the error in the Postman test script to assert the response status is 200.
pm.test("Status code is 200", function () { pm.response.to.have.status([1]); });
The status method expects the numeric status code 200 to check for success.
Fill both blanks to create a JSON body and send it with a POST request using REST-assured.
given().contentType("application/json").body([1]).when().post("/create").then().statusCode([2]);
The JSON body must be a string with the data. Status code 201 means resource created successfully.
Fill all three blanks to extract a JSON field and assert its value in a Postman test script.
pm.test("Check user name", function () { let jsonData = pm.response.json(); pm.expect(jsonData.[1]).to.eql([2]); pm.expect(pm.response.code).to.equal([3]); });
jsonData.user.name accesses the name field. The expected value is "John". The status code should be 200 for success.