Reputation: 1115
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.sstatic.net/P3RSe.png [2]: https://i.sstatic.net/cRzZ8.png [3]: https://i.sstatic.net/l3GmM.png
Upvotes: 0
Views: 239
Reputation: 168002
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
Upvotes: 0