Complete the code to check if the request body is not empty before sending.
if ([1]) { pm.sendRequest(request, callback); }
The pm.request.body.raw contains the raw body content as a string. Checking it ensures the body is not empty before sending.
Complete the code to validate that the JSON body contains a 'name' field before sending.
const body = JSON.parse(pm.request.body.raw); if (body.[1]) { pm.sendRequest(request, callback); }
The 'name' field is required in the JSON body. Checking body.name ensures it exists before sending.
Fix the error in the code to correctly validate the body length before sending.
if (pm.request.body.raw.[1] > 0) { pm.sendRequest(request, callback); }
length() which causes a runtime error.size or count which are not valid string properties.The length property gives the number of characters in the string. Using length() causes an error because it's not a function.
Fill both blanks to parse the JSON body and check if the 'age' field is greater than 18 before sending.
const data = JSON.parse(pm.request.body.[1]); if (data.[2] > 18) { pm.sendRequest(request, callback); }
Use pm.request.body.raw to get the raw JSON string, then check data.age to validate the age field.
Fill all three blanks to create a validation that sends the request only if the body has a 'status' field equal to 'active'.
const body = JSON.parse(pm.request.body.[1]); if (body.[2] === [3]) { pm.sendRequest(request, callback); }
Parse the raw body string, then check if body.status equals the string "active" before sending.