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

1 Like

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.