0
votes

I have a simple thread group with HTTP requests as below:

Do Login - POST request

  • grab the authorization bearer token

Get eventId - GET request

When I run the above, the Login post request goes through fine. I get a 200 OK and the response header ad message looks fine. But the 'Get eventId' request fails and returns a 400 Bad Request.

However when I start JMeter to go through the proxy like below, the 'Get eventId' request returns a 200 OK and the response looks as expected. jmeter.bat -H 127.0.0.1 -P 8888

I am not sure what I am doing wrong?

1
Revisit the steps: 1. grab the authorization bearer token (what is the "reference name" of the token?) e.g. "authToken" and how you fetch it? 2. Pass the proper "reference name" in HTTP Header Manager e.g. Name: Authorization Value: Bearer ${authToken}Yugal
I use a regular expression extractor to fetch the Authorization: Bearer {TOKEN}. This is then passed to the Get EventID request in its header. The format is fine. It works when I send the JMeter request through Fiddler.rhanabe
Look at the Bearer {TOKEN} passed in the "Get eventId" call's Request Headers.Yugal

1 Answers

0
votes

As per 400 Bad Request status code description:

The HyperText Transfer Protocol (HTTP) 400 Bad Request response status code indicates that the server could not understand the request due to invalid syntax.

Most likely you need to add HTTP Header Manager to send Content-Type header with the value of application/json (or whatever MIME type server expects).

If this is not the case - inspect what is being sent in both cases using View Results Tree listener and amend JMeter configuration so requests would look exactly the same (apart from dynamic token)