To send a request via the sandbox, you can use pm.sendRequest.
pm.test("Status code is 200", function () {
pm.sendRequest('https://postman-echo.com/get', function (err, res) {
pm.expect(err).to.not.be.ok;
pm.expect(res).to.have.property('code', 200);
pm.expect(res).to.have.property('status', 'OK');
});
});
Without additional options, this will sent a GET request to the URL specified. If you prefer to be more explicit, you can use the complete syntax:
pm.sendRequest({
url: 'https://postman-echo.com/post',
method: 'POST',
header: 'headername1:value1',
body: {
mode: 'raw',
raw: JSON.stringify({ key: "this is json" })
}
}, function (err, res) {
console.log(res);
});
Hi,
I'm having trouble with sendRequest.
My Request looks like this:
When I send this to my endpoint, the body of the request appears to be empty on the server side.
When I send the same request with the regular postman GUI I have no trouble and the endpoint works.
I logged the body to the console just to be sure, it's not an issue with the environment variable, but everything looks normal there:
Has anyone seen something like this before?
Is this an Issue with Postman?