401 Unauthorized on 3rd and beyond request using Runner to iterate through CSV

I receive a ā€œ401 Unauthorizedā€ error on the 3rd, 4th, 5th, etc request when using the Runner to iterate through a CSV file.

The first two requests are just fine, the 3rd and beyond fail.

Interestingly, Iā€™ve found that if I run 2 iterations, then 3 iterations, then the whole set, I can get through a successful run.

This has been manageable for now to get a set of tests written and tested, but now Iā€™m looking to execute this set via command line using newman as part of our daily build process and the error continues, and itā€™s not obvious how to implement the same work around via command line.

Whatā€™s going on here? Thanks for any assistance!

1 Like

Here is a screen cap of a successful run when using the Run 2 iterations, then Run 3 iterations, then Run the whole set work around. NTLM settings are unchanged from the 401 execution, the script is identical, etc:

@rustoleum76 There might be some sort of rate limiting at play. Can you try adding a delay of ā€œ2000ā€ in the runner UI? (This will add a delay of 2 seconds between each request)

Hi @abhijit,
thanks for your reply.

The 2000ms delay doesnā€™t change anything unfortunately.

Iā€™ve learned more about Postman and JS and have dug deeper.

The problem seems related to a JSON.parse(responseBody) call in ā€œTestsā€

Object:{}
message:"Unexpected token ā€˜<ā€™ at 1:1 <!DOCTYPE html PUBLIC ā€œ-//W3C//DTD XHTML 1.0 Strict//ENā€ "http://www.w3.org/TR/ ^"
name:"JSONError"
type:ā€œErrorā€

learning moreā€¦ the above error is a red herring. The json parse problem comes because an invalid response was received due to the previously determined 401 Unauthorized.

The Response:

401 - Unauthorized: Access is denied due to invalid credentials.

Server Error

401 - Unauthorized: Access is denied due to invalid credentials.

You do not have permission to view this directory or page using the credentials that you supplied.

And looking at the server that Iā€™m calling to, I can see the requests and response code:

2018-02-07 22:27:37 IP_redacted POST /AnalyticsServices/AccruedInterest/CalcAccruedInterest - 443 - IP2_redacted PostmanRuntime/7.1.1 - 401 2 5 0
2018-02-07 22:27:37 IP_redacted POST /AnalyticsServices/AccruedInterest/CalcAccruedInterest - 443 DOMAIN\User IP2_redacted PostmanRuntime/7.1.1 - 200 0 0 42
2018-02-07 22:27:37 IP_redacted POST /AnalyticsServices/AccruedInterest/CalcAccruedInterest - 443 DOMAIN\User IP2_redacted PostmanRuntime/7.1.1 - 200 0 0 26
2018-02-07 22:27:37 IP_redacted POST /AnalyticsServices/AccruedInterest/CalcAccruedInterest - 443 - IP2_redacted PostmanRuntime/7.1.1 - 401 1 2148074248 0
2018-02-07 22:27:37 IP_redacted POST /AnalyticsServices/AccruedInterest/CalcAccruedInterest - 443 - IP2_redacted PostmanRuntime/7.1.1 - 401 1 2148074248 0
2018-02-07 22:27:37 IP_redacted POST /AnalyticsServices/AccruedInterest/CalcAccruedInterest - 443 - IP2_redacted PostmanRuntime/7.1.1 - 401 1 2148074248 0

The first two succeed with status 200 (and also w/ credentials being passed). Subsequent requests return 401 and I can see no credentials being passed.

So, it seems like the Runner process is not sending the NTLM credentials correctly at each iteration, except when I do the weird workaround where I run 2, then run 3 and then run the test.

Incidentally, when I do that, I can see each succeeding request does indeed have user details specified:

2018-02-07 22:10:12 IP_redacted POST /AnalyticsServices/AccruedInterest/CalcAccruedInterest - 443 - IP2_redacted PostmanRuntime/7.1.1 - 401 2 5 0
2018-02-07 22:10:12 IP_redacted POST /AnalyticsServices/AccruedInterest/CalcAccruedInterest - 443 DOMAIN\USER IP2_redacted PostmanRuntime/7.1.1 - 200 0 0 46
2018-02-07 22:10:12 IP_redacted POST /AnalyticsServices/AccruedInterest/CalcAccruedInterest - 443 DOMAIN\USER IP2_redacted PostmanRuntime/7.1.1 - 200 0 0 31
2018-02-07 22:10:20 IP_redacted POST /AnalyticsServices/AccruedInterest/CalcAccruedInterest - 443 DOMAIN\USER IP2_redacted PostmanRuntime/7.1.1 - 200 0 0 15
2018-02-07 22:10:20 IP_redacted POST /AnalyticsServices/AccruedInterest/CalcAccruedInterest - 443 DOMAIN\USER IP2_redacted PostmanRuntime/7.1.1 - 200 0 0 13
2018-02-07 22:10:20 IP_redacted POST /AnalyticsServices/AccruedInterest/CalcAccruedInterest - 443 DOMAIN\USER IP2_redacted PostmanRuntime/7.1.1 - 200 0 0 31
2018-02-07 22:10:28 IP_redacted POST /AnalyticsServices/AccruedInterest/CalcAccruedInterest - 443 DOMAIN\USER IP2_redacted PostmanRuntime/7.1.1 - 200 0 0 19
2018-02-07 22:10:28 IP_redacted POST /AnalyticsServices/AccruedInterest/CalcAccruedInterest - 443 DOMAIN\USER IP2_redacted PostmanRuntime/7.1.1 - 200 0 0 31
2018-02-07 22:10:28 IP_redacted POST /AnalyticsServices/AccruedInterest/CalcAccruedInterest - 443 DOMAIN\USER IP2_redacted PostmanRuntime/7.1.1 - 200 0 0 31

Hi @abhijit, i have the same issue. The first 2 tests are passing and the remaining I am getting the error ā€œUnauthorized: Access is denied due to invalid credentialsā€

Hello folks,

Any update on this?
Did you find any solution or exact issue for that?

Thanks,
Ashutosh Singh

Itā€™s hard to tell without knowing more about your test scripts.
If you check the HTTP response code before trying to parse your response body you certainly can avoid the JSON error (itā€™s not really a red herring after all ;)).

If you log some information in your tests you probably can see whatā€™s going on with your iterations and where/why it starts to fail.

In my script I am doing nothing except making calls to same service 10 times using runner.
I am not processing any response.

But the solution suggested above by running runner first for 1 iteration, then for 2 and then for as many as you want it doesnt fail.

this sounds more like an issue with your service.

Dear POSTMAN team. Please responce on this topic. This problem is alive since 2018 till NOW (04.2020). Thanks this issue you men lose your money simply why firms dont want purchase PRO version cause the COLLECTION RUNNER simply can not be applied for couple of real projects.

1 Like

I have the same issue. For the first 2 iterations, there is no issue. The subsequent iterations giving the Unauthorization error. I am using NTLM authentication and I pass Username and Password. For the first 2 iterations, the NTLM auth key is unique , but on the next iterations, the auth key is similar to the 2nd iteration. i.e. somehow postman is keeping the auth key in memory and applying the same from 3rd iteration on words rather generation new key.

Hello,
Iā€™d like to verify that this is still an issue in the most recent version of Postman. I have a collection of services that use Windows authentication and if I select any set of 3 or more, the first two will execute properly, returning 200ā€™s, and the rest will 401. Setting delays between the service calls of up to 5000 ms has no positive effect.

Has there been a solution or workaround identified for this?

1 Like

Hello,

And once more using Postman 10.14.5 currently the latest and still experiencing the same problems as described above.

Hey guys! I encountered the same error. I use NTLM authentification. I checked ā€œYes, disable retrying the requestā€ in the ā€œAuthorizationā€ tab, saved, ran the collection then disabled the option again, saved and ran the collection. It fixed the issue.