1
votes

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.

2
The error implies that the request is not a proper JSON(as you have specified content-type:application/json). Can you share what exactly does the API expect as request parameter?Simrandeep Singh
It is expecting a parameter 'fields' and its value is a list of properties that i want returned. Specifically I want the users 'id' returned, so I am passing the parameter ?fields=['id']. If I send the parameter via the Path, it gives the error mentioned above about it must be a valid JSON. If I try to send the parameter via the 'Send Parameters With the Request' section, as far as I can tell it is not being sent at all, and gives me an error that the fields parameter is missing.MSD
Show how you submit in postmanuser7294900
More confusion: In Postman if I use double quotes for ["id"] it works. If I use single, I get the same 'must be valid json' error. However in JMeter, if I use double quotes, it gives me an error that im using illegal characters.MSD
@user7294900 in Postman, I send that exact same request as in my original post, except i use double quotes. In JMeter, double quotes give me an error for an illegal character.MSD

2 Answers

2
votes

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.

0
votes
  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