0

I want to post json data to the endpoint using JMeter and I become 400 error. My test case is as follows

The request:

[![enter image description here][1]][1]

Instead of Data I use a legit Data.

The header manager:

[![enter image description here][2]][2]

The header with content-type being provided

[![enter image description here][3]][3]

I do not realy understand why the request is bad. I have the same request in Postman and it is working there just ok.

EDIT: I can not use Script Recorder since there are two Proxies. Use JMeter Proxy against specific Proxy to record requests and that is not working also. [1]: https://i.stack.imgur.com/P3RSe.png [2]: https://i.stack.imgur.com/cRzZ8.png [3]: https://i.stack.imgur.com/l3GmM.png

FarFarAway
  • 1,017
  • 3
  • 14
  • 35
  • There seems to be some issue with the request payload you are passing in POST Body. Make sure the JSON is correctly formatted. – Raj Jul 10 '20 at 12:22
  • I have verified the JSON file. Its the same as the request in postman and I had it with https://jsonformatter.curiousconcept.com/ verified, the json Data are fine – FarFarAway Jul 10 '20 at 13:15

1 Answers1

0

My expectation is that your request fails because you are sending ${DATA} as it is and it's not a valid JSON payload.

If you have a JMeter Variable called DATA then you need to use the following syntax:

${DATA}

if you have a file with JSON data you need to use __FileToString() function like:

${__FileToString(/path/to/your/file.json,,)}

Going forward if you encounter a situation when test is working fine in Postman and not in JMeter it means that your JMeter configuration is not correct and the easiest way to get the "correct" configuration is just recording the request which is being sent by Postman using JMeter's HTTP(S) Test Script Recorder

Dmitri T
  • 159,985
  • 5
  • 83
  • 133