JMeter 5.0: How to send HTTP Request with body data?












0














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










share|improve this question





























    0














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










    share|improve this question



























      0












      0








      0







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










      share|improve this question















      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






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Dec 28 '18 at 15:56







      rmarques

















      asked Dec 27 '18 at 18:32









      rmarquesrmarques

      217




      217






















          2 Answers
          2






          active

          oldest

          votes


















          1














          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"
          }
          }
          }


          enter image description here



          I can see the request body exactly as I defined in the View Results Tree listener



          enter image description here



          And the response contains all the relevant search results:



          enter image description here





          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





          1. 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"




          2. Prepare Postman for recording




            • from Postman main menu choose File -> Settings -> Proxy


            • tick both HTTP and HTTPS protocols and set proxy server to 127.0.0.1:8888



              enter image description here





          3. Execute your request in Postman


          4. JMeter should capture it under the Recording Controller. If everything goes well you should be able to replay it without any issues.






          share|improve this answer





















          • 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










          • 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



















          0














          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!






          share|improve this answer





















            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
            });


            }
            });














            draft saved

            draft discarded


















            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









            1














            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"
            }
            }
            }


            enter image description here



            I can see the request body exactly as I defined in the View Results Tree listener



            enter image description here



            And the response contains all the relevant search results:



            enter image description here





            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





            1. 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"




            2. Prepare Postman for recording




              • from Postman main menu choose File -> Settings -> Proxy


              • tick both HTTP and HTTPS protocols and set proxy server to 127.0.0.1:8888



                enter image description here





            3. Execute your request in Postman


            4. JMeter should capture it under the Recording Controller. If everything goes well you should be able to replay it without any issues.






            share|improve this answer





















            • 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










            • 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
















            1














            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"
            }
            }
            }


            enter image description here



            I can see the request body exactly as I defined in the View Results Tree listener



            enter image description here



            And the response contains all the relevant search results:



            enter image description here





            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





            1. 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"




            2. Prepare Postman for recording




              • from Postman main menu choose File -> Settings -> Proxy


              • tick both HTTP and HTTPS protocols and set proxy server to 127.0.0.1:8888



                enter image description here





            3. Execute your request in Postman


            4. JMeter should capture it under the Recording Controller. If everything goes well you should be able to replay it without any issues.






            share|improve this answer





















            • 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










            • 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














            1












            1








            1






            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"
            }
            }
            }


            enter image description here



            I can see the request body exactly as I defined in the View Results Tree listener



            enter image description here



            And the response contains all the relevant search results:



            enter image description here





            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





            1. 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"




            2. Prepare Postman for recording




              • from Postman main menu choose File -> Settings -> Proxy


              • tick both HTTP and HTTPS protocols and set proxy server to 127.0.0.1:8888



                enter image description here





            3. Execute your request in Postman


            4. JMeter should capture it under the Recording Controller. If everything goes well you should be able to replay it without any issues.






            share|improve this answer












            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"
            }
            }
            }


            enter image description here



            I can see the request body exactly as I defined in the View Results Tree listener



            enter image description here



            And the response contains all the relevant search results:



            enter image description here





            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





            1. 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"




            2. Prepare Postman for recording




              • from Postman main menu choose File -> Settings -> Proxy


              • tick both HTTP and HTTPS protocols and set proxy server to 127.0.0.1:8888



                enter image description here





            3. Execute your request in Postman


            4. JMeter should capture it under the Recording Controller. If everything goes well you should be able to replay it without any issues.







            share|improve this answer












            share|improve this answer



            share|improve this answer










            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










            • 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


















            • 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










            • 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
















            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













            0














            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!






            share|improve this answer


























              0














              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!






              share|improve this answer
























                0












                0








                0






                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!






                share|improve this answer












                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!







                share|improve this answer












                share|improve this answer



                share|improve this answer










                answered Dec 29 '18 at 10:35









                rmarquesrmarques

                217




                217






























                    draft saved

                    draft discarded




















































                    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.




                    draft saved


                    draft discarded














                    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





















































                    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







                    Popular posts from this blog

                    Probability when a professor distributes a quiz and homework assignment to a class of n students.

                    Aardman Animations

                    Are they similar matrix