JMeter 5.0: How to send HTTP Request with body data?
This may be a duplicate from https://stackoverflow.com/questions/40514004/jmeter-how-to-send-get-request-with-body-data
But despite the guys on that question claiming it is solved on version 3.1 of JMeter, it is not working as I expected on JMeter 5.0.
I also tried to set Content-Type: application/x-www-form-urlencoded on a HTTP Request Manager associated to the HTTP Request Sampler but the body is only passed on POST requests. My app receives nicely from Postman but not from JMeter.
EDIT: This is the Code snippet generated by Postman:
GET /api/patients/5c1e35351f68df799c0ad864/cases HTTP/1.1
Host: localhost:3080
Content-Type: application/json
Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJlbWFpbCI6InJ1YmVubWFycXVlczkxQGdtYWlsLmNvbSIsInVzZXJJZCI6IjVjMjNiZTJkNjU0YjIwMzhiNDQwY2ViZiIsImlhdCI6MTU0NjAxMjQ2NSwiZXhwIjoxNTQ2MDE2MDY1fQ.LqCV9eHByxQ0ubDIcJOwR0WGGXfMw49X0VLLurjbseM
cache-control: no-cache
Postman-Token: 2d8f4f4c-4ec6-428e-bf1a-cafd27fa98ed
{
"caseName": "TestName"
}------WebKitFormBoundary7MA4YWxkTrZu0gW--
jmeter postman
add a comment |
This may be a duplicate from https://stackoverflow.com/questions/40514004/jmeter-how-to-send-get-request-with-body-data
But despite the guys on that question claiming it is solved on version 3.1 of JMeter, it is not working as I expected on JMeter 5.0.
I also tried to set Content-Type: application/x-www-form-urlencoded on a HTTP Request Manager associated to the HTTP Request Sampler but the body is only passed on POST requests. My app receives nicely from Postman but not from JMeter.
EDIT: This is the Code snippet generated by Postman:
GET /api/patients/5c1e35351f68df799c0ad864/cases HTTP/1.1
Host: localhost:3080
Content-Type: application/json
Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJlbWFpbCI6InJ1YmVubWFycXVlczkxQGdtYWlsLmNvbSIsInVzZXJJZCI6IjVjMjNiZTJkNjU0YjIwMzhiNDQwY2ViZiIsImlhdCI6MTU0NjAxMjQ2NSwiZXhwIjoxNTQ2MDE2MDY1fQ.LqCV9eHByxQ0ubDIcJOwR0WGGXfMw49X0VLLurjbseM
cache-control: no-cache
Postman-Token: 2d8f4f4c-4ec6-428e-bf1a-cafd27fa98ed
{
"caseName": "TestName"
}------WebKitFormBoundary7MA4YWxkTrZu0gW--
jmeter postman
add a comment |
This may be a duplicate from https://stackoverflow.com/questions/40514004/jmeter-how-to-send-get-request-with-body-data
But despite the guys on that question claiming it is solved on version 3.1 of JMeter, it is not working as I expected on JMeter 5.0.
I also tried to set Content-Type: application/x-www-form-urlencoded on a HTTP Request Manager associated to the HTTP Request Sampler but the body is only passed on POST requests. My app receives nicely from Postman but not from JMeter.
EDIT: This is the Code snippet generated by Postman:
GET /api/patients/5c1e35351f68df799c0ad864/cases HTTP/1.1
Host: localhost:3080
Content-Type: application/json
Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJlbWFpbCI6InJ1YmVubWFycXVlczkxQGdtYWlsLmNvbSIsInVzZXJJZCI6IjVjMjNiZTJkNjU0YjIwMzhiNDQwY2ViZiIsImlhdCI6MTU0NjAxMjQ2NSwiZXhwIjoxNTQ2MDE2MDY1fQ.LqCV9eHByxQ0ubDIcJOwR0WGGXfMw49X0VLLurjbseM
cache-control: no-cache
Postman-Token: 2d8f4f4c-4ec6-428e-bf1a-cafd27fa98ed
{
"caseName": "TestName"
}------WebKitFormBoundary7MA4YWxkTrZu0gW--
jmeter postman
This may be a duplicate from https://stackoverflow.com/questions/40514004/jmeter-how-to-send-get-request-with-body-data
But despite the guys on that question claiming it is solved on version 3.1 of JMeter, it is not working as I expected on JMeter 5.0.
I also tried to set Content-Type: application/x-www-form-urlencoded on a HTTP Request Manager associated to the HTTP Request Sampler but the body is only passed on POST requests. My app receives nicely from Postman but not from JMeter.
EDIT: This is the Code snippet generated by Postman:
GET /api/patients/5c1e35351f68df799c0ad864/cases HTTP/1.1
Host: localhost:3080
Content-Type: application/json
Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJlbWFpbCI6InJ1YmVubWFycXVlczkxQGdtYWlsLmNvbSIsInVzZXJJZCI6IjVjMjNiZTJkNjU0YjIwMzhiNDQwY2ViZiIsImlhdCI6MTU0NjAxMjQ2NSwiZXhwIjoxNTQ2MDE2MDY1fQ.LqCV9eHByxQ0ubDIcJOwR0WGGXfMw49X0VLLurjbseM
cache-control: no-cache
Postman-Token: 2d8f4f4c-4ec6-428e-bf1a-cafd27fa98ed
{
"caseName": "TestName"
}------WebKitFormBoundary7MA4YWxkTrZu0gW--
jmeter postman
jmeter postman
edited Dec 28 '18 at 15:56
rmarques
asked Dec 27 '18 at 18:32
rmarquesrmarques
217
217
add a comment |
add a comment |
2 Answers
2
active
oldest
votes
What exactly doesn't work? For example, given the following Elastic search payload:
{
"index": {
"_index": "shakespeare",
"_type": "act",
"_id": 0
}
}
{
"line_id": 1,
"play_name": "Henry IV",
"speech_number": "",
"line_number": "",
"speaker": "",
"text_entry": "ACT I"
}
When I execute the following GET request:
{
"query": {
"match": {
"play_name": "Henry IV"
}
}
}
I can see the request body exactly as I defined in the View Results Tree listener
And the response contains all the relevant search results:
So I would recommend comparing the requests which are being sent by Postman and JMeter using a sniffer tool like Fiddler or Wireshark. Most probably there is an error in JMeter configuration, presumably connected with wrong Content-Type
Also be aware that it is possible to record the request sent from Postman using JMeter's HTTP(S) Test Script Recorder
Prepare JMeter for recording. The easiest way of doing this is using JMeter Templates feature
- from JMeter's main menu choose
File -> Templates -> Recording
and click "Create" - Open HTTP(S) Test Script Recorder and click "Start"
- from JMeter's main menu choose
Prepare Postman for recording
- from Postman main menu choose
File -> Settings -> Proxy
tick both
HTTP
andHTTPS
protocols and set proxy server to127.0.0.1:8888
- from Postman main menu choose
Execute your request in Postman
- JMeter should capture it under the Recording Controller. If everything goes well you should be able to replay it without any issues.
The problem is that the body of the request is empty on the server side. But it is not when using Postman...
– rmarques
Dec 28 '18 at 13:48
The problem is that you're configuring JMeter differently and expect the same behavior. Same requests will produce the same response.
– Dmitri T
Dec 28 '18 at 13:49
I know, I just can't point out what I'm doing differently. I setup the recording as instructed, I think, and it didn't record anything into the Recording Controller by the way.
– rmarques
Dec 28 '18 at 14:14
Clickcode
button in Postman and update the question with the request: i.stack.imgur.com/851pU.png
– Dmitri T
Dec 28 '18 at 14:30
Ok, I've updated the question
– rmarques
Dec 28 '18 at 14:42
|
show 4 more comments
The problem was in the configuration o JMeter. I was using the Parameters tab of HTTP request and putting properties on the Name tab and values on the Value tab.
An illuminated user posted this: https://stackoverflow.com/a/51609079/3267330.
I don't know why my initial approach worked on POST, PATCH and PUT requests and not on GET requests specifically, but now I'm just sticking with putting the body of all my requests on the Body Data tab and creating a Header with Content-Type: application/json
because THAT works!
add a comment |
Your Answer
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "3"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fsuperuser.com%2fquestions%2f1388201%2fjmeter-5-0-how-to-send-http-request-with-body-data%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
What exactly doesn't work? For example, given the following Elastic search payload:
{
"index": {
"_index": "shakespeare",
"_type": "act",
"_id": 0
}
}
{
"line_id": 1,
"play_name": "Henry IV",
"speech_number": "",
"line_number": "",
"speaker": "",
"text_entry": "ACT I"
}
When I execute the following GET request:
{
"query": {
"match": {
"play_name": "Henry IV"
}
}
}
I can see the request body exactly as I defined in the View Results Tree listener
And the response contains all the relevant search results:
So I would recommend comparing the requests which are being sent by Postman and JMeter using a sniffer tool like Fiddler or Wireshark. Most probably there is an error in JMeter configuration, presumably connected with wrong Content-Type
Also be aware that it is possible to record the request sent from Postman using JMeter's HTTP(S) Test Script Recorder
Prepare JMeter for recording. The easiest way of doing this is using JMeter Templates feature
- from JMeter's main menu choose
File -> Templates -> Recording
and click "Create" - Open HTTP(S) Test Script Recorder and click "Start"
- from JMeter's main menu choose
Prepare Postman for recording
- from Postman main menu choose
File -> Settings -> Proxy
tick both
HTTP
andHTTPS
protocols and set proxy server to127.0.0.1:8888
- from Postman main menu choose
Execute your request in Postman
- JMeter should capture it under the Recording Controller. If everything goes well you should be able to replay it without any issues.
The problem is that the body of the request is empty on the server side. But it is not when using Postman...
– rmarques
Dec 28 '18 at 13:48
The problem is that you're configuring JMeter differently and expect the same behavior. Same requests will produce the same response.
– Dmitri T
Dec 28 '18 at 13:49
I know, I just can't point out what I'm doing differently. I setup the recording as instructed, I think, and it didn't record anything into the Recording Controller by the way.
– rmarques
Dec 28 '18 at 14:14
Clickcode
button in Postman and update the question with the request: i.stack.imgur.com/851pU.png
– Dmitri T
Dec 28 '18 at 14:30
Ok, I've updated the question
– rmarques
Dec 28 '18 at 14:42
|
show 4 more comments
What exactly doesn't work? For example, given the following Elastic search payload:
{
"index": {
"_index": "shakespeare",
"_type": "act",
"_id": 0
}
}
{
"line_id": 1,
"play_name": "Henry IV",
"speech_number": "",
"line_number": "",
"speaker": "",
"text_entry": "ACT I"
}
When I execute the following GET request:
{
"query": {
"match": {
"play_name": "Henry IV"
}
}
}
I can see the request body exactly as I defined in the View Results Tree listener
And the response contains all the relevant search results:
So I would recommend comparing the requests which are being sent by Postman and JMeter using a sniffer tool like Fiddler or Wireshark. Most probably there is an error in JMeter configuration, presumably connected with wrong Content-Type
Also be aware that it is possible to record the request sent from Postman using JMeter's HTTP(S) Test Script Recorder
Prepare JMeter for recording. The easiest way of doing this is using JMeter Templates feature
- from JMeter's main menu choose
File -> Templates -> Recording
and click "Create" - Open HTTP(S) Test Script Recorder and click "Start"
- from JMeter's main menu choose
Prepare Postman for recording
- from Postman main menu choose
File -> Settings -> Proxy
tick both
HTTP
andHTTPS
protocols and set proxy server to127.0.0.1:8888
- from Postman main menu choose
Execute your request in Postman
- JMeter should capture it under the Recording Controller. If everything goes well you should be able to replay it without any issues.
The problem is that the body of the request is empty on the server side. But it is not when using Postman...
– rmarques
Dec 28 '18 at 13:48
The problem is that you're configuring JMeter differently and expect the same behavior. Same requests will produce the same response.
– Dmitri T
Dec 28 '18 at 13:49
I know, I just can't point out what I'm doing differently. I setup the recording as instructed, I think, and it didn't record anything into the Recording Controller by the way.
– rmarques
Dec 28 '18 at 14:14
Clickcode
button in Postman and update the question with the request: i.stack.imgur.com/851pU.png
– Dmitri T
Dec 28 '18 at 14:30
Ok, I've updated the question
– rmarques
Dec 28 '18 at 14:42
|
show 4 more comments
What exactly doesn't work? For example, given the following Elastic search payload:
{
"index": {
"_index": "shakespeare",
"_type": "act",
"_id": 0
}
}
{
"line_id": 1,
"play_name": "Henry IV",
"speech_number": "",
"line_number": "",
"speaker": "",
"text_entry": "ACT I"
}
When I execute the following GET request:
{
"query": {
"match": {
"play_name": "Henry IV"
}
}
}
I can see the request body exactly as I defined in the View Results Tree listener
And the response contains all the relevant search results:
So I would recommend comparing the requests which are being sent by Postman and JMeter using a sniffer tool like Fiddler or Wireshark. Most probably there is an error in JMeter configuration, presumably connected with wrong Content-Type
Also be aware that it is possible to record the request sent from Postman using JMeter's HTTP(S) Test Script Recorder
Prepare JMeter for recording. The easiest way of doing this is using JMeter Templates feature
- from JMeter's main menu choose
File -> Templates -> Recording
and click "Create" - Open HTTP(S) Test Script Recorder and click "Start"
- from JMeter's main menu choose
Prepare Postman for recording
- from Postman main menu choose
File -> Settings -> Proxy
tick both
HTTP
andHTTPS
protocols and set proxy server to127.0.0.1:8888
- from Postman main menu choose
Execute your request in Postman
- JMeter should capture it under the Recording Controller. If everything goes well you should be able to replay it without any issues.
What exactly doesn't work? For example, given the following Elastic search payload:
{
"index": {
"_index": "shakespeare",
"_type": "act",
"_id": 0
}
}
{
"line_id": 1,
"play_name": "Henry IV",
"speech_number": "",
"line_number": "",
"speaker": "",
"text_entry": "ACT I"
}
When I execute the following GET request:
{
"query": {
"match": {
"play_name": "Henry IV"
}
}
}
I can see the request body exactly as I defined in the View Results Tree listener
And the response contains all the relevant search results:
So I would recommend comparing the requests which are being sent by Postman and JMeter using a sniffer tool like Fiddler or Wireshark. Most probably there is an error in JMeter configuration, presumably connected with wrong Content-Type
Also be aware that it is possible to record the request sent from Postman using JMeter's HTTP(S) Test Script Recorder
Prepare JMeter for recording. The easiest way of doing this is using JMeter Templates feature
- from JMeter's main menu choose
File -> Templates -> Recording
and click "Create" - Open HTTP(S) Test Script Recorder and click "Start"
- from JMeter's main menu choose
Prepare Postman for recording
- from Postman main menu choose
File -> Settings -> Proxy
tick both
HTTP
andHTTPS
protocols and set proxy server to127.0.0.1:8888
- from Postman main menu choose
Execute your request in Postman
- JMeter should capture it under the Recording Controller. If everything goes well you should be able to replay it without any issues.
answered Dec 28 '18 at 12:35
Dmitri TDmitri T
22112
22112
The problem is that the body of the request is empty on the server side. But it is not when using Postman...
– rmarques
Dec 28 '18 at 13:48
The problem is that you're configuring JMeter differently and expect the same behavior. Same requests will produce the same response.
– Dmitri T
Dec 28 '18 at 13:49
I know, I just can't point out what I'm doing differently. I setup the recording as instructed, I think, and it didn't record anything into the Recording Controller by the way.
– rmarques
Dec 28 '18 at 14:14
Clickcode
button in Postman and update the question with the request: i.stack.imgur.com/851pU.png
– Dmitri T
Dec 28 '18 at 14:30
Ok, I've updated the question
– rmarques
Dec 28 '18 at 14:42
|
show 4 more comments
The problem is that the body of the request is empty on the server side. But it is not when using Postman...
– rmarques
Dec 28 '18 at 13:48
The problem is that you're configuring JMeter differently and expect the same behavior. Same requests will produce the same response.
– Dmitri T
Dec 28 '18 at 13:49
I know, I just can't point out what I'm doing differently. I setup the recording as instructed, I think, and it didn't record anything into the Recording Controller by the way.
– rmarques
Dec 28 '18 at 14:14
Clickcode
button in Postman and update the question with the request: i.stack.imgur.com/851pU.png
– Dmitri T
Dec 28 '18 at 14:30
Ok, I've updated the question
– rmarques
Dec 28 '18 at 14:42
The problem is that the body of the request is empty on the server side. But it is not when using Postman...
– rmarques
Dec 28 '18 at 13:48
The problem is that the body of the request is empty on the server side. But it is not when using Postman...
– rmarques
Dec 28 '18 at 13:48
The problem is that you're configuring JMeter differently and expect the same behavior. Same requests will produce the same response.
– Dmitri T
Dec 28 '18 at 13:49
The problem is that you're configuring JMeter differently and expect the same behavior. Same requests will produce the same response.
– Dmitri T
Dec 28 '18 at 13:49
I know, I just can't point out what I'm doing differently. I setup the recording as instructed, I think, and it didn't record anything into the Recording Controller by the way.
– rmarques
Dec 28 '18 at 14:14
I know, I just can't point out what I'm doing differently. I setup the recording as instructed, I think, and it didn't record anything into the Recording Controller by the way.
– rmarques
Dec 28 '18 at 14:14
Click
code
button in Postman and update the question with the request: i.stack.imgur.com/851pU.png– Dmitri T
Dec 28 '18 at 14:30
Click
code
button in Postman and update the question with the request: i.stack.imgur.com/851pU.png– Dmitri T
Dec 28 '18 at 14:30
Ok, I've updated the question
– rmarques
Dec 28 '18 at 14:42
Ok, I've updated the question
– rmarques
Dec 28 '18 at 14:42
|
show 4 more comments
The problem was in the configuration o JMeter. I was using the Parameters tab of HTTP request and putting properties on the Name tab and values on the Value tab.
An illuminated user posted this: https://stackoverflow.com/a/51609079/3267330.
I don't know why my initial approach worked on POST, PATCH and PUT requests and not on GET requests specifically, but now I'm just sticking with putting the body of all my requests on the Body Data tab and creating a Header with Content-Type: application/json
because THAT works!
add a comment |
The problem was in the configuration o JMeter. I was using the Parameters tab of HTTP request and putting properties on the Name tab and values on the Value tab.
An illuminated user posted this: https://stackoverflow.com/a/51609079/3267330.
I don't know why my initial approach worked on POST, PATCH and PUT requests and not on GET requests specifically, but now I'm just sticking with putting the body of all my requests on the Body Data tab and creating a Header with Content-Type: application/json
because THAT works!
add a comment |
The problem was in the configuration o JMeter. I was using the Parameters tab of HTTP request and putting properties on the Name tab and values on the Value tab.
An illuminated user posted this: https://stackoverflow.com/a/51609079/3267330.
I don't know why my initial approach worked on POST, PATCH and PUT requests and not on GET requests specifically, but now I'm just sticking with putting the body of all my requests on the Body Data tab and creating a Header with Content-Type: application/json
because THAT works!
The problem was in the configuration o JMeter. I was using the Parameters tab of HTTP request and putting properties on the Name tab and values on the Value tab.
An illuminated user posted this: https://stackoverflow.com/a/51609079/3267330.
I don't know why my initial approach worked on POST, PATCH and PUT requests and not on GET requests specifically, but now I'm just sticking with putting the body of all my requests on the Body Data tab and creating a Header with Content-Type: application/json
because THAT works!
answered Dec 29 '18 at 10:35
rmarquesrmarques
217
217
add a comment |
add a comment |
Thanks for contributing an answer to Super User!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fsuperuser.com%2fquestions%2f1388201%2fjmeter-5-0-how-to-send-http-request-with-body-data%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown