Trying to prevent 302 redirect when loading script via eval

In my request, I load, via a globals variable, some javascript and do an eval on it so I can call it and set up my tests (rather than trying to include a bunch of requests from other collections and having to maintain all of those requests).

I have my request set up (under settings), in postman, to ignore 302 redirects. I have found that when doing a “pm.sendRequest()” from within the "eval"d code in the pre-request script, that the pm object does not abide by the setting for the request (to ignore redirects) and will continue to accept the 302 and follow it. However, if I am in the request itself (the actual running of the request), then the 302-redirect is ignored correctly.

Does anyone know of any way to modify the pm object itself within the eval’d script to force it to also ignore the 302 redirect? I even tried passing in the pm object into my eval’d script to see if it was different in some way, but that did not work either.

I know everyone likes a follow up :slight_smile:

So I tried running my collection via newman passing in --ignore-redirects and lo-and-behold, it works or at least agrees to not follow redirects. I’ll be using this via CI/CD pipelines, so while it’s a little more difficult using the UI to do this, there is at least a work around for it.

However, this would be nice to be able to make the pm object configurable within the pm.sendRequest (maybe an override config) right off the bat (pre-request scripts also) rather than the settings only happening during the actual request itself as right now, running it via newman, I am preventing it following 302s for the entire collection run vs. for a specific request.