When i POST a URL with Headers with Body data it is working fine in J METER -HTTP API request i get the following Error - api

In POSTMAN when i POST a URL with Headers with Body data it is working fine and getting Response as 200,but when i POST the same in J meter HTTP API request i am receiving the following Error.
Headers size in bytes: 124
Body size in bytes: 54
Sample Count: 1
Error Count: 1
Data type ("text"|"bin"|""): text
Response code: 404
Response message: Resource Not Found

If you're sending the same requests you should be getting the same responses. HTTP Status Code 404 means that URL path is not correct so you need to check the path of your URL as most probably there is a difference there. Even non-printable characters which you cannot see in JMeter GUI are encoded into their equivalents so whitespace becomes %20 so pay attention to literally everything.
In any case given you can successfully execute the request in Postman it means that you can record it using JMeter's HTTP(S) Test Script Recorder
Prepare JMeter for recording, the easiest way is using JMeter Templates Feature
once JMeter creates a Test Plan for your - expand and start the HTTP(S) Test Script Recorder
Prepare Postman for recording, configure it to use JMeter as the proxy:
Run your request in Postman
That's it, JMeter should capture the request and save it under the Recording Controller along with the HTTP Header Manager containing corresponding request headers

Related

What are the actual request headers sent in the Intellij HTTP client?

IntelliJ has an HTTP client. When composing a file that is interpreted by the HTTP client, you can specify headers that go out to the server with the request, like so:
###
GET https://{{hostname}}/{{path}}
Content-Type: application/json
X-Auth-Token: {{x-token}}
I want to find the actual value of the token that was used to replace the variable name, seen above as {{x-token}}, but I don't see any way to obtain the request headers. The response headers are obviously available, but not the request headers. See the image below for the test results that are shown after running the HTTP client inside Intellij:
Is there a way to display the REQUEST headers?
Link to IntelliJ Documentation - HTTP Client -- the documentation seems to never mention the actual request headers that are sent over the wire, but they do discuss how to define request headers in composing the .http file type.
Check the Tools | HTTP Client | 'Show HHTP Requests History' action.

Jmeter showing response code as 300 in response

I am working in a desktop application which contains API as well.
So when I try to hit the API using Jmeter with the local server name as localhost. I am getting the response as below
Response code:300
Response message:MULTIPLE CHOICES
Response data:
{"succeed": false, "error_message": "No data JSON received!"}
Even I tried with the Content-Type as application/json and multipart/form-data, but not worked.
Note: When I try to hit the same API using Postman, I got the 200 status.
If you're able to successfully execute the request using Postman you should be able to do this using JMeter as well. We cannot state what's wrong without seeing your Postman and JMeter configurations, just make sure that everything is the same:
request URL
request bosy
request headers
etc.
If you will send the same request - you will get the same response.
Be aware that you can just record the request from Postman using JMeter
Start JMeter's HTTP(S) Test Script Recorder
If you're using HTTPS protocol - import JMeter's certificate into Postman
Configure Postman to use JMeter as the proxy
Run your request in Postman
JMeter will capture the request and generate relevant HTTP Request sampler and HTTP Header Manager
More information: How to Convert Your Postman API Tests to JMeter for Scaling

Same HTTPS request works in Postman but gives 400 Bad Request in JMeter

I think I tried all the possible combinations of headers and body for my POST request in JMeter but is giving me 400 Bad Request saying that the languagePairID parameter from the body is invalid even tho it is exactly same as in Postman.
My headers:
And the request:
Meanwhile in Postman in works perfectly fine:
I tried checking and unchecking the multipart/form-data and browser-compatible headers, but nothing seems to help. I read that using Wireshark might be useful in such cases but I think for this one is not possible as it is HTTPS. I will be very grateful for any advice.
Uncheck "Use mutipart/form-data"
Remove everything from the "Body Data" tab
Switch to "Parameters" tab and put your parameters there:
Going forward be informed that you can easily convert your Postman script into JMeter:
Start JMeter's HTTP(S) Test Script Recorder
Import JMeter's certificate to Postman
Configure Postman to use JMeter as the proxy
Run your request in Postman
JMeter will capture the request and generate relevant HTTP Request sampler and HTTP Header Manager
More information: How to Convert Your Postman API Tests to JMeter for Scaling

Bad Request : 400, when generating bearer token for OAuth2.0

I have setup an api in jmeter which will generate the bearer token for OAuth 2.0. When checking the request body in view result tree listener, seems like jmeter is not parsing the -Client Secret key.
request making
View Result tree - Request body
Response - 400
Please try the below,
Tried it on postman, (working fine)
Now from JMeter, (working fine)
I guess you missed the checkboxes (URL Encode?) in the request parameters in the Jmeter section
HTTP Status 400 means "bad request", one of your request parameters is not correct, like URL or request data or request headers, cross check them with browser/postman
If you're able to successfully execute the request using Postman you can just record the request from Postman using JMeter's HTTP(S) Test Script Recorder
Start JMeter proxy server
Configure Postman to use JMeter as the proxy
Run your request in Postman
JMeter will capture the request and generate appropriate HTTP Request sampler and HTTP Header Manager
More information: How to Convert Your Postman API Tests to JMeter for Scaling

Jmeter - POST API not working

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:
And my HTTP Request Header looks like this:
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!
If your application works fine with Postman the fastest and the easiest way of building JMeter test plan will be just recording it using JMeter's HTTP(S) Test Script Recorder.
Prepare JMeter for recording (you can do it in a few clicks via JMeter Templates Feature)
from JMeter's main menu choose File -> Templates -> Recording and click "Create"
Expand Workbench - HTTP(S) Test Script Recorder and click "Start"
Prepare Postman for recording
In order to "tell" Postman to use JMeter as a proxy you need to provide --proxy-server parameter to it like:
C:\Users\YOUR_USER_NAME\AppData\Local\Postman\app-x.x.x\Postman.exe --proxy-server=localhost:8888
Execute your requests in Postman
JMeter will capture requests, convert them into HTTP Request samplers and store them under Test Plan -> Thread Group -> Recording Controller
References:
JMeter Proxy Step by Step
How to configure Postman Native Client App to use an external proxy
By seeing the image you have attached you are missing / in the path.
the path should be /registerMobileUsingCode
if it is working fine from POSTMAN, then your port 8080 is fine.
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.