I’m trying to migrate some Postman Collection to Postman v12 for my team but I have an issue when I execute pm.sendRequest from Before Request script in Collection.
I did a small tests using a Test Collection and the Request works as expected when using Postman Cloud however the same Request fails when running from Native GIT in Postman.
Can someone please confirm if this is expected or maybe a known issue?
Hey @maintenance-technol7! Thanks for the report. I can notice some inconsistencies in the mentioned workflow. We’ll look into this and provide an update here once the fix is out.
It looks like the same issue I’m experiencing. Posted in Discord:
I tried using the Git-backed workspace. In the pre-request script I’m using pm.sendRequest to send a request to an unrelated API. The engine is not calling the additional API, but instead is triggering the pre-request script again - resulting in an infinite loop (I have console.log in my script) and Postman getting stuck.
Adding this in the pre-request script fixes the issue:
Thanks @guyarad for the workaround! I was experiencing the exact same issue — pm.sendRequest in a collection-level pre-request script was causing an infinite loop and crashing Postman in my Git-backed workspace. Adding the URL guard to short-circuit the pre-request script when the request matches the external API resolved it.
Hopefully the Postman team addresses this soon so pm.sendRequest behaves consistently between Git-backed and regular workspaces without needing a workaround.
Updated Before Request:
const externalAPI = 'https://postman-echo.com/get';
if (pm.request.url.toString() == externalAPI) {
console.log("External request — skipping pre-request auth:", pm.request.url.toString());
return;
}
pm.test("Status code is 200", function () {
pm.sendRequest(externalAPI, 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');
});
});
@maintenance-technol7@guyarad This issue is now resolved in the latest version of the Postman app (v12.2.0). Please update your app to receive the fix. Let us know if you encounter any further issues.