MSD
MSD

Reputation: 51

JMeter Cant make GET HTTP request work, works fine in PostMan

I'm trying to do a GET HTTPS Request via JMeter. It is a simple request with content-type=application/json, and an auth token. Now for unknown reasons it works perfectly without any issues/problems in Postman, but in JMeter I'm getting an error.

I'm new to JMeter so I can only assume I am just setting something incorrectly.

The HTTP Request I am sending is:

 https://www.server.com/api/userinfo?fields=['id'] 

In postman I get a 200 response with the expected JSON response. In JMeter however, it gives me the error:

Could not parse fields query. Must be valid JSON.

I've tried messing with the 'send parameters with the request' option in JMeter by removing the ?fields=['id'] from the Path, and instead setting them in the parameters area, but that gives me the exact same 400 error response code.

Also, if I use the send parameters section, and I look at the request, it doesn't seem to be using the parameters i've set. So I went back to passing the parameter directly in the URL path.

Upvotes: 1

Views: 4812

Answers (2)

MSD
MSD

Reputation: 51

SOLVED:: The issue is that JMeter does not like the usage of double quotes in the Path field. You can get by this by using %22 in place of double quotes. This solved the problem of not receiving an error when passing the parameter through Path.

Upvotes: 2

Dmitri T
Dmitri T

Reputation: 168072

  1. Add HTTP Request sampler to your Test Plan
  2. Configure it as follows:

    enter image description here

  3. You might also need to add HTTP Header Manager as a child of your request and configure it to send the relevant Content-Type header

The sent data can be verified using View Results Tree listener:

enter image description here


Also be aware that you can easily create a JMeter test from Postman by just recording the request using HTTP(S) Test Script Recorder

Upvotes: 0

Related Questions