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);
});
@arun-a-nayagam I have seen stuff like that happen because the "pm.test" block finishes executing before the rest call is completed... I haven't found any other way to solve that but using setTimeout... I would try putting a timeout probably in the getApp call
And see what that does... or maybe around the whole pm.test
setTimeout(() => {
pm.test("Apps", function () {
...
})
) },2000)
EDIT: I came back here because for some reason your issue kept revolving inside my head, and found a few things I think need to be pointed out