0
votes

I'm creating a load test with JMeter. I'm trying to make a Post request to create a new resource but it always responds with 500 error, even though I'm sending the same headers and parameters as the browser and I also tried with postman and it works fine, it's just with JMeter that's not working.

The script was recorded with the BlazeMeter Chrome extension and adjusted as needed.

The next configurations are for the Test Plan in general:

  • HTTP Header Manager with the header "User-Agent".
  • User Defined Variables with only one variable "BASE_URL_1".
  • HTTP Request Defaults with the "Retrieve All Embedded Resources" and "Parallel downloads" selected and "Number" set to 6.
  • DNS Cache Manager with "Clear cache each iteration" selected and "Use system DNS resolver".
  • HTTP Authorization Manager with nothing selected.
  • HTTP Cookie Manager with "Clear cookies each iteration?" selected.
  • HTTP Cache Manager with "Clear cache each iteration?" selected and "Max Number of elements in cache" set to 5000.

I set the "CookieManager.save.cookies" option to "true" in "jmeter.properties".

Here's an image of what the "HTTP Request" looks like:

Image of the Post HTTP Request

Inside the "HTTP Request" there's a "HTTP Header Manager" with the next headers:

Image of the HTTP Header Manager

Inside the "HTTP Request" there's also a "Uniform Random Timer" with "Random Delay Maximum" set to 26344.0 and "Constant Delay Offset" set to 13172.

The cookies seemed to be sent fine with the session data. I do log in a user and get the session data before attempting to do the post request and other get requests work fine under the same session. I teste this same headers with Postman and it worked. I have no idea why this is not working in JMeter. I tried doing several changes to the configuration without success. This is a .NET service.

The API is not built the best way, but what makes me think that this 500 error might be from JMeter and not the API is that I was able to successfully make the request from postman.

Anyone has an idea of what could be wrong on the test config?

EDIT

Here are some images from the View Results Tree:

Sampler Result Sampler Result

Request Body Request Body

Request Headers Request Headers

Response Headers Response Headers

The Response Body is HTML saying that there's an error.

1
you want the port to be 80?user7294900
Try removing "Content-type" and check in the multipart-form data also it will be good if you post images from view result treeMohamed Sulaimaan Sheriff
Hello @user7294900, I'm not really sure, I created the test with the BlazeMeter recorder.dolivas
Hi @zeeshan I tried removing the "Content-Type" and checked the miltipart-form data but I get the same error. Also, will update the post with the result tree images.dolivas

1 Answers

1
votes

Given your request works in Postman you should be able to record it using JMeter's HTTP(S) Test Script Recorder.

  1. Prepare JMeter for recording, the fastest and the easiest way is using JMeter Templates feature

    • From JMeter's main menu choose File -> Template -> Recording and click "Create"
    • Open HTTP(S) Test Script Recorder and click "Start"
  2. Prepare Postman for recording.

    • From Postman main menu choose File -> Settings -> Proxy
    • Use 127.0.0.1 as the proxy host and 8888 as the proxy port

      enter image description here

  3. Run your request in Postman

  4. JMeter will capture the request under the Recording Controller
  5. Parameterize and correlate the request
  6. It should be working fine. If not - compare the requests which are being sent by Postman and JMeter using a 3rd-party sniffer tool like Wireshark of Fiddler, detect and eliminate any inconsistencies.