How to make the search parameters in http request as dynamic in jmeter












0














http request: http://ipAddress:Port/SomeResource?Param1=value1&Param2=value2&......



so on.
This is a http request sample in jmeter that hits a rest api and gets response in JSON format.



Here the challenge is Param1, param2, param3 .... these search parameters number is not constant it may change depending on the call so i am making a csv file that contains rows that contain search parameters in coma separated format.






CSV file is like
param1,param2
param1,param2,param3
param1





I am using a CSV data configure to pull data from the csv file and put it in the http request



enter image description here



And putting this in http request like



enter image description here



Now if the param is null i don't want see this in http request header
so how to do this in jmeter.










share|improve this question





























    0














    http request: http://ipAddress:Port/SomeResource?Param1=value1&Param2=value2&......



    so on.
    This is a http request sample in jmeter that hits a rest api and gets response in JSON format.



    Here the challenge is Param1, param2, param3 .... these search parameters number is not constant it may change depending on the call so i am making a csv file that contains rows that contain search parameters in coma separated format.






    CSV file is like
    param1,param2
    param1,param2,param3
    param1





    I am using a CSV data configure to pull data from the csv file and put it in the http request



    enter image description here



    And putting this in http request like



    enter image description here



    Now if the param is null i don't want see this in http request header
    so how to do this in jmeter.










    share|improve this question



























      0












      0








      0







      http request: http://ipAddress:Port/SomeResource?Param1=value1&Param2=value2&......



      so on.
      This is a http request sample in jmeter that hits a rest api and gets response in JSON format.



      Here the challenge is Param1, param2, param3 .... these search parameters number is not constant it may change depending on the call so i am making a csv file that contains rows that contain search parameters in coma separated format.






      CSV file is like
      param1,param2
      param1,param2,param3
      param1





      I am using a CSV data configure to pull data from the csv file and put it in the http request



      enter image description here



      And putting this in http request like



      enter image description here



      Now if the param is null i don't want see this in http request header
      so how to do this in jmeter.










      share|improve this question















      http request: http://ipAddress:Port/SomeResource?Param1=value1&Param2=value2&......



      so on.
      This is a http request sample in jmeter that hits a rest api and gets response in JSON format.



      Here the challenge is Param1, param2, param3 .... these search parameters number is not constant it may change depending on the call so i am making a csv file that contains rows that contain search parameters in coma separated format.






      CSV file is like
      param1,param2
      param1,param2,param3
      param1





      I am using a CSV data configure to pull data from the csv file and put it in the http request



      enter image description here



      And putting this in http request like



      enter image description here



      Now if the param is null i don't want see this in http request header
      so how to do this in jmeter.






      CSV file is like
      param1,param2
      param1,param2,param3
      param1





      CSV file is like
      param1,param2
      param1,param2,param3
      param1






      rest http testing jmeter jsr223






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Nov 20 at 6:24

























      asked Nov 20 at 5:11









      venkat sai

      608




      608
























          1 Answer
          1






          active

          oldest

          votes


















          1
















          1. Remove all "Parameters" from the HTTP Request, it should be clean



            enter image description here



          2. Add JSR223 PreProcessor as a child of the HTTP Request sampler you would like to parameterize


          3. Put the following code into "Script" area:



            1.upto(4, {
            if (vars.get('param' + "$it") != null) {
            sampler.addArgument(vars.get('param' + "$it"),'someValue')
            }
            })


          4. Add JSR223 PostProcessor as a child of the request you would like to parameterize


          5. Put the following code into "Script" area:



            1.upto(4, {
            vars.remove("param" + "$it")
            })



          6. That's it, you should now get what you need. You will not see the changes in JMeter GUI, you will only be able to observe them in the runtime using View Results Tree listener



            enter image description here








          share|improve this answer





















          • Sir can you explain or share some link to understand how this works, because i am unable to understand how this thing works.
            – venkat sai
            Nov 20 at 8:36






          • 1




            vars is a shorthand for JMeterVariables class, it is used for getting param1, param2, etc. variables values. sampler is a shorthand for HTTPSamplerProxy class, it's used for adding request parameters. Check out Top 8 JMeter Java Classes You Should Be Using with Groovy for the most commonly used functions.
            – Dmitri T
            Nov 20 at 8:47










          • Thank you sir for explaining me the way this works and i'm sure this solution works for my problem
            – venkat sai
            Nov 20 at 9:13











          Your Answer






          StackExchange.ifUsing("editor", function () {
          StackExchange.using("externalEditor", function () {
          StackExchange.using("snippets", function () {
          StackExchange.snippets.init();
          });
          });
          }, "code-snippets");

          StackExchange.ready(function() {
          var channelOptions = {
          tags: "".split(" "),
          id: "1"
          };
          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%2fstackoverflow.com%2fquestions%2f53386601%2fhow-to-make-the-search-parameters-in-http-request-as-dynamic-in-jmeter%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown

























          1 Answer
          1






          active

          oldest

          votes








          1 Answer
          1






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes









          1
















          1. Remove all "Parameters" from the HTTP Request, it should be clean



            enter image description here



          2. Add JSR223 PreProcessor as a child of the HTTP Request sampler you would like to parameterize


          3. Put the following code into "Script" area:



            1.upto(4, {
            if (vars.get('param' + "$it") != null) {
            sampler.addArgument(vars.get('param' + "$it"),'someValue')
            }
            })


          4. Add JSR223 PostProcessor as a child of the request you would like to parameterize


          5. Put the following code into "Script" area:



            1.upto(4, {
            vars.remove("param" + "$it")
            })



          6. That's it, you should now get what you need. You will not see the changes in JMeter GUI, you will only be able to observe them in the runtime using View Results Tree listener



            enter image description here








          share|improve this answer





















          • Sir can you explain or share some link to understand how this works, because i am unable to understand how this thing works.
            – venkat sai
            Nov 20 at 8:36






          • 1




            vars is a shorthand for JMeterVariables class, it is used for getting param1, param2, etc. variables values. sampler is a shorthand for HTTPSamplerProxy class, it's used for adding request parameters. Check out Top 8 JMeter Java Classes You Should Be Using with Groovy for the most commonly used functions.
            – Dmitri T
            Nov 20 at 8:47










          • Thank you sir for explaining me the way this works and i'm sure this solution works for my problem
            – venkat sai
            Nov 20 at 9:13
















          1
















          1. Remove all "Parameters" from the HTTP Request, it should be clean



            enter image description here



          2. Add JSR223 PreProcessor as a child of the HTTP Request sampler you would like to parameterize


          3. Put the following code into "Script" area:



            1.upto(4, {
            if (vars.get('param' + "$it") != null) {
            sampler.addArgument(vars.get('param' + "$it"),'someValue')
            }
            })


          4. Add JSR223 PostProcessor as a child of the request you would like to parameterize


          5. Put the following code into "Script" area:



            1.upto(4, {
            vars.remove("param" + "$it")
            })



          6. That's it, you should now get what you need. You will not see the changes in JMeter GUI, you will only be able to observe them in the runtime using View Results Tree listener



            enter image description here








          share|improve this answer





















          • Sir can you explain or share some link to understand how this works, because i am unable to understand how this thing works.
            – venkat sai
            Nov 20 at 8:36






          • 1




            vars is a shorthand for JMeterVariables class, it is used for getting param1, param2, etc. variables values. sampler is a shorthand for HTTPSamplerProxy class, it's used for adding request parameters. Check out Top 8 JMeter Java Classes You Should Be Using with Groovy for the most commonly used functions.
            – Dmitri T
            Nov 20 at 8:47










          • Thank you sir for explaining me the way this works and i'm sure this solution works for my problem
            – venkat sai
            Nov 20 at 9:13














          1












          1








          1








          1. Remove all "Parameters" from the HTTP Request, it should be clean



            enter image description here



          2. Add JSR223 PreProcessor as a child of the HTTP Request sampler you would like to parameterize


          3. Put the following code into "Script" area:



            1.upto(4, {
            if (vars.get('param' + "$it") != null) {
            sampler.addArgument(vars.get('param' + "$it"),'someValue')
            }
            })


          4. Add JSR223 PostProcessor as a child of the request you would like to parameterize


          5. Put the following code into "Script" area:



            1.upto(4, {
            vars.remove("param" + "$it")
            })



          6. That's it, you should now get what you need. You will not see the changes in JMeter GUI, you will only be able to observe them in the runtime using View Results Tree listener



            enter image description here








          share|improve this answer














          1. Remove all "Parameters" from the HTTP Request, it should be clean



            enter image description here



          2. Add JSR223 PreProcessor as a child of the HTTP Request sampler you would like to parameterize


          3. Put the following code into "Script" area:



            1.upto(4, {
            if (vars.get('param' + "$it") != null) {
            sampler.addArgument(vars.get('param' + "$it"),'someValue')
            }
            })


          4. Add JSR223 PostProcessor as a child of the request you would like to parameterize


          5. Put the following code into "Script" area:



            1.upto(4, {
            vars.remove("param" + "$it")
            })



          6. That's it, you should now get what you need. You will not see the changes in JMeter GUI, you will only be able to observe them in the runtime using View Results Tree listener



            enter image description here









          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Nov 20 at 6:39









          Dmitri T

          68.9k33458




          68.9k33458












          • Sir can you explain or share some link to understand how this works, because i am unable to understand how this thing works.
            – venkat sai
            Nov 20 at 8:36






          • 1




            vars is a shorthand for JMeterVariables class, it is used for getting param1, param2, etc. variables values. sampler is a shorthand for HTTPSamplerProxy class, it's used for adding request parameters. Check out Top 8 JMeter Java Classes You Should Be Using with Groovy for the most commonly used functions.
            – Dmitri T
            Nov 20 at 8:47










          • Thank you sir for explaining me the way this works and i'm sure this solution works for my problem
            – venkat sai
            Nov 20 at 9:13


















          • Sir can you explain or share some link to understand how this works, because i am unable to understand how this thing works.
            – venkat sai
            Nov 20 at 8:36






          • 1




            vars is a shorthand for JMeterVariables class, it is used for getting param1, param2, etc. variables values. sampler is a shorthand for HTTPSamplerProxy class, it's used for adding request parameters. Check out Top 8 JMeter Java Classes You Should Be Using with Groovy for the most commonly used functions.
            – Dmitri T
            Nov 20 at 8:47










          • Thank you sir for explaining me the way this works and i'm sure this solution works for my problem
            – venkat sai
            Nov 20 at 9:13
















          Sir can you explain or share some link to understand how this works, because i am unable to understand how this thing works.
          – venkat sai
          Nov 20 at 8:36




          Sir can you explain or share some link to understand how this works, because i am unable to understand how this thing works.
          – venkat sai
          Nov 20 at 8:36




          1




          1




          vars is a shorthand for JMeterVariables class, it is used for getting param1, param2, etc. variables values. sampler is a shorthand for HTTPSamplerProxy class, it's used for adding request parameters. Check out Top 8 JMeter Java Classes You Should Be Using with Groovy for the most commonly used functions.
          – Dmitri T
          Nov 20 at 8:47




          vars is a shorthand for JMeterVariables class, it is used for getting param1, param2, etc. variables values. sampler is a shorthand for HTTPSamplerProxy class, it's used for adding request parameters. Check out Top 8 JMeter Java Classes You Should Be Using with Groovy for the most commonly used functions.
          – Dmitri T
          Nov 20 at 8:47












          Thank you sir for explaining me the way this works and i'm sure this solution works for my problem
          – venkat sai
          Nov 20 at 9:13




          Thank you sir for explaining me the way this works and i'm sure this solution works for my problem
          – venkat sai
          Nov 20 at 9:13


















          draft saved

          draft discarded




















































          Thanks for contributing an answer to Stack Overflow!


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





          Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


          Please pay close attention to the following guidance:


          • 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%2fstackoverflow.com%2fquestions%2f53386601%2fhow-to-make-the-search-parameters-in-http-request-as-dynamic-in-jmeter%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

          "Incorrect syntax near the keyword 'ON'. (on update cascade, on delete cascade,)

          Alcedinidae

          Origin of the phrase “under your belt”?