Jmeter - POST API not working

Viewed 5313

I am new to Jmeter and have been struggling to get it working to test my POST API. It works fine for a GET API call where I pass the parameters through the Parameters tab.

Details here:

server name: localhost port: 8080 path /registerMobileUsingCode

In the request body, I am sending the following:

{ "clientName": "DemoOrg", "code": "9880007615", "languageId": "1" }

My Jmeter setup looks like this:

1

And my HTTP Request Header looks like this:

Request Header details

The API is in production and works fine with postman.

I am just unable to get it working through JMeter. It is obvious that I am doing something wrong but can't figure out what despite having spent a considerable amount of time Googling for solutions.

Any help would be much appreciated.

UPDATE - 1 - Updated with jmeter log as suggested

Thread Name: Thread Group 1-1 Sample Start: 2017-08-09 17:03:41 IST Load time: 1604 Connect Time: 1525 Latency: 1604 Size in bytes: 399 Sent bytes:251 Headers size in bytes: 213 Body size in bytes: 186 Sample Count: 1 Error Count: 1 Data type ("text"|"bin"|""): text Response code: 500 Response message: Server Level Exception encountered

Response headers: HTTP/1.1 500 Server Level Exception encountered Date: Wed, 09 Aug 2017 11:33:43 GMT Access-Control-Allow-Origin: * Content-Type: application/json Transfer-Encoding: chunked Server: Jetty(9.2.16.v20160414)

HTTPSampleResult fields: ContentType: application/json DataEncoding: null

UPDATE-2 - Using Postman and JMeter Recorder

As suggested by @Dimitri T, I downloaded the Linux version of Postman and started it with --proxy-server=localhost:8888.

I was now able to make a Postman request and capture the request in JMeter. Here is what the request looked like:

Jmeter capture of a Postman Request

As you can see, nothing radically different from what I did. However, this DOES work! So hurray!

2 Answers

By seeing the image you have attached you are missing / in the path.

the path should be /registerMobileUsingCode

  1. if it is working fine from POSTMAN, then your port 8080 is fine.
  2. Can you please confirm what is the data type of your request? looks like languageId is integer so you should be using languageId: 1, instead of languageId: "1". The integer should not be double quotes.
Related