I want to send the request sent by postman to jmeter

85 Views Asked by At

I want to changing test tool from postman to jmeter.

Usual body format was raw-json, I did well without any problems. But this case I should change form-data.

First, Postman confirmed response(return 200) and data check in db(maria-db). But it continues to fail in jmeter.

Below is the data I saved in postman. enter image description here

I configured jmeter as shown in the picture, but it doesn't work. Help me enter image description here

I changed config many time.

enter image description here

enter image description here

2

There are 2 best solutions below

6
On

Your Postman example is not a raw\JSON request.

It's a form that has an JSON string in the value.

If needed, the header needs to be set to "multipart/form-data".

You add the elements to the request using the "Use multipart/form-data" option (as you have selected in your second screenshot) and then use the parameter tab (with the name being the key, and the value being the JSON) rather than the "Body Data" tab.

Here is my example, sending data to Postman Echo.

enter image description here

Using the JMeter proxy as a way of recording a Postman request is a decent way of working out what a request needs if you are not sure.

You can also use the code snippets options in Postman which will show you the code for different programming languages included CURL (which will show something like the following)

curl --location 'https://postman-echo.com/post' \
--header 'Cookie: sails.sid=s%3AsToeDnYuKjkLNh_xIGLN3-bQiTCuPt3j.5h3g7HutPvu2D2IYJ2peGzcT731EqhUhsp5cUdFrtpo' \
--form 'createRoom="{\"room\":{\"roomid\": 100,\"name\":\"test01\"}}"'

You can then import that into JMeter using "Import from cURL" under the tools menu.

enter image description here

This created an nearly identical request to the one I setup manually.

enter image description here

3
On

It looks like a copy-paste issue, you're sending an incomplete request. Also it doesn't look like a valid JSON to me.

You might also need to add a HTTP Header Manager and configure it to send Content-Type header with the value of application/json

In general if your request can be successfully executed in Postman nothing prevents you from just recording it using JMeter's HTTP(S) Test Script Recorder

  1. Configure Postman to use JMeter as the proxy

    enter image description here

  2. Import JMeter's certificate into Postman

    enter image description here

  3. Run your request in Postman - JMeter will generate the relevant HTTP Request sampler which can be replayed later on.