Dynamic entry while posting a json body in jmeter











up vote
0
down vote

favorite












I been trying to write jmeter load test for a SAML secured web-service. So for i have a http request sampler which gets the access code and stores in a variable named access_code. But the web-service accepts post request in the form:



api.service.edu/api/authentication with body data as { "code":"${access_code}","redirect_uri":"some site"} .



but whenever I tried running the jmeter , my sampler gives the following error :



Thread Name: Basic App Usage Flow 1-1
Sample Start: 2018-11-07 21:08:50 EST
Load time: 1209
Connect Time: 0
Latency: 1208
Size in bytes: 370
Sent bytes:0
Headers size in bytes: 324
Body size in bytes: 46
Sample Count: 1
Error Count: 1
Data type ("text"|"bin"|""): text
Response code: 500
Response message: Internal Server Error



HTTPSampleResult fields:
ContentType: application/json; charset=utf-8
DataEncoding: utf-8



is it because of the way I am parsing the access_code? if so how can I parse a dynamic value via a json post request?.










share|improve this question


























    up vote
    0
    down vote

    favorite












    I been trying to write jmeter load test for a SAML secured web-service. So for i have a http request sampler which gets the access code and stores in a variable named access_code. But the web-service accepts post request in the form:



    api.service.edu/api/authentication with body data as { "code":"${access_code}","redirect_uri":"some site"} .



    but whenever I tried running the jmeter , my sampler gives the following error :



    Thread Name: Basic App Usage Flow 1-1
    Sample Start: 2018-11-07 21:08:50 EST
    Load time: 1209
    Connect Time: 0
    Latency: 1208
    Size in bytes: 370
    Sent bytes:0
    Headers size in bytes: 324
    Body size in bytes: 46
    Sample Count: 1
    Error Count: 1
    Data type ("text"|"bin"|""): text
    Response code: 500
    Response message: Internal Server Error



    HTTPSampleResult fields:
    ContentType: application/json; charset=utf-8
    DataEncoding: utf-8



    is it because of the way I am parsing the access_code? if so how can I parse a dynamic value via a json post request?.










    share|improve this question
























      up vote
      0
      down vote

      favorite









      up vote
      0
      down vote

      favorite











      I been trying to write jmeter load test for a SAML secured web-service. So for i have a http request sampler which gets the access code and stores in a variable named access_code. But the web-service accepts post request in the form:



      api.service.edu/api/authentication with body data as { "code":"${access_code}","redirect_uri":"some site"} .



      but whenever I tried running the jmeter , my sampler gives the following error :



      Thread Name: Basic App Usage Flow 1-1
      Sample Start: 2018-11-07 21:08:50 EST
      Load time: 1209
      Connect Time: 0
      Latency: 1208
      Size in bytes: 370
      Sent bytes:0
      Headers size in bytes: 324
      Body size in bytes: 46
      Sample Count: 1
      Error Count: 1
      Data type ("text"|"bin"|""): text
      Response code: 500
      Response message: Internal Server Error



      HTTPSampleResult fields:
      ContentType: application/json; charset=utf-8
      DataEncoding: utf-8



      is it because of the way I am parsing the access_code? if so how can I parse a dynamic value via a json post request?.










      share|improve this question













      I been trying to write jmeter load test for a SAML secured web-service. So for i have a http request sampler which gets the access code and stores in a variable named access_code. But the web-service accepts post request in the form:



      api.service.edu/api/authentication with body data as { "code":"${access_code}","redirect_uri":"some site"} .



      but whenever I tried running the jmeter , my sampler gives the following error :



      Thread Name: Basic App Usage Flow 1-1
      Sample Start: 2018-11-07 21:08:50 EST
      Load time: 1209
      Connect Time: 0
      Latency: 1208
      Size in bytes: 370
      Sent bytes:0
      Headers size in bytes: 324
      Body size in bytes: 46
      Sample Count: 1
      Error Count: 1
      Data type ("text"|"bin"|""): text
      Response code: 500
      Response message: Internal Server Error



      HTTPSampleResult fields:
      ContentType: application/json; charset=utf-8
      DataEncoding: utf-8



      is it because of the way I am parsing the access_code? if so how can I parse a dynamic value via a json post request?.







      jmeter saml-2.0






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Nov 8 at 2:11









      Harun Guna

      113




      113
























          1 Answer
          1






          active

          oldest

          votes

















          up vote
          0
          down vote















          1. HTTP Status Code 500 stands for Internal Server Error, according to HTTP protocol specification the problem is on the server side as client status codes (i.e. malformed requests) should have HTTP Status code between 400 and 499. So I would recommend checking server-side logs, most probably you will be able to figure out what's wrong from them.

          2. It might be the case your ${access_code} variable is not defined, i.e. the relevant Post-Processor failed to extract it from the previous response. Double check it's value using Debug Sampler and View Results Tree listener combination


          3. It might be the case your ${access_code} variable contains some special characters which are not allowed in JSON and must be escaped





            • Backspace is replaced with b


            • Form feed is replaced with f


            • Newline is replaced with n


            • Carriage return is replaced with r


            • Tab is replaced with t


            • Double quote is replaced with "


            • Backslash is replaced with \


            If your ${access_code} variable contains any of the above - the resulting JSON will be incorrect. To be on the safe side I would recommend replacing your ${access_code} variable reference with __groovy() function call



            ${__groovy(org.apache.commons.lang3.StringEscapeUtils.escapeJson(vars.get('access_code')),)}


          4. It might be the case you're not sending a proper Content-Type header so make sure to add HTTP Header Manager and configure it to send application/json as the Content-Type






          share|improve this answer





















          • Thank you for the reply. I found that I am not receiving the access_code from the previous sampler. I am still going to replace the ${access_code} with the groovy function.
            – Harun Guna
            Nov 8 at 20:46











          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',
          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%2f53200580%2fdynamic-entry-while-posting-a-json-body-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








          up vote
          0
          down vote















          1. HTTP Status Code 500 stands for Internal Server Error, according to HTTP protocol specification the problem is on the server side as client status codes (i.e. malformed requests) should have HTTP Status code between 400 and 499. So I would recommend checking server-side logs, most probably you will be able to figure out what's wrong from them.

          2. It might be the case your ${access_code} variable is not defined, i.e. the relevant Post-Processor failed to extract it from the previous response. Double check it's value using Debug Sampler and View Results Tree listener combination


          3. It might be the case your ${access_code} variable contains some special characters which are not allowed in JSON and must be escaped





            • Backspace is replaced with b


            • Form feed is replaced with f


            • Newline is replaced with n


            • Carriage return is replaced with r


            • Tab is replaced with t


            • Double quote is replaced with "


            • Backslash is replaced with \


            If your ${access_code} variable contains any of the above - the resulting JSON will be incorrect. To be on the safe side I would recommend replacing your ${access_code} variable reference with __groovy() function call



            ${__groovy(org.apache.commons.lang3.StringEscapeUtils.escapeJson(vars.get('access_code')),)}


          4. It might be the case you're not sending a proper Content-Type header so make sure to add HTTP Header Manager and configure it to send application/json as the Content-Type






          share|improve this answer





















          • Thank you for the reply. I found that I am not receiving the access_code from the previous sampler. I am still going to replace the ${access_code} with the groovy function.
            – Harun Guna
            Nov 8 at 20:46















          up vote
          0
          down vote















          1. HTTP Status Code 500 stands for Internal Server Error, according to HTTP protocol specification the problem is on the server side as client status codes (i.e. malformed requests) should have HTTP Status code between 400 and 499. So I would recommend checking server-side logs, most probably you will be able to figure out what's wrong from them.

          2. It might be the case your ${access_code} variable is not defined, i.e. the relevant Post-Processor failed to extract it from the previous response. Double check it's value using Debug Sampler and View Results Tree listener combination


          3. It might be the case your ${access_code} variable contains some special characters which are not allowed in JSON and must be escaped





            • Backspace is replaced with b


            • Form feed is replaced with f


            • Newline is replaced with n


            • Carriage return is replaced with r


            • Tab is replaced with t


            • Double quote is replaced with "


            • Backslash is replaced with \


            If your ${access_code} variable contains any of the above - the resulting JSON will be incorrect. To be on the safe side I would recommend replacing your ${access_code} variable reference with __groovy() function call



            ${__groovy(org.apache.commons.lang3.StringEscapeUtils.escapeJson(vars.get('access_code')),)}


          4. It might be the case you're not sending a proper Content-Type header so make sure to add HTTP Header Manager and configure it to send application/json as the Content-Type






          share|improve this answer





















          • Thank you for the reply. I found that I am not receiving the access_code from the previous sampler. I am still going to replace the ${access_code} with the groovy function.
            – Harun Guna
            Nov 8 at 20:46













          up vote
          0
          down vote










          up vote
          0
          down vote











          1. HTTP Status Code 500 stands for Internal Server Error, according to HTTP protocol specification the problem is on the server side as client status codes (i.e. malformed requests) should have HTTP Status code between 400 and 499. So I would recommend checking server-side logs, most probably you will be able to figure out what's wrong from them.

          2. It might be the case your ${access_code} variable is not defined, i.e. the relevant Post-Processor failed to extract it from the previous response. Double check it's value using Debug Sampler and View Results Tree listener combination


          3. It might be the case your ${access_code} variable contains some special characters which are not allowed in JSON and must be escaped





            • Backspace is replaced with b


            • Form feed is replaced with f


            • Newline is replaced with n


            • Carriage return is replaced with r


            • Tab is replaced with t


            • Double quote is replaced with "


            • Backslash is replaced with \


            If your ${access_code} variable contains any of the above - the resulting JSON will be incorrect. To be on the safe side I would recommend replacing your ${access_code} variable reference with __groovy() function call



            ${__groovy(org.apache.commons.lang3.StringEscapeUtils.escapeJson(vars.get('access_code')),)}


          4. It might be the case you're not sending a proper Content-Type header so make sure to add HTTP Header Manager and configure it to send application/json as the Content-Type






          share|improve this answer














          1. HTTP Status Code 500 stands for Internal Server Error, according to HTTP protocol specification the problem is on the server side as client status codes (i.e. malformed requests) should have HTTP Status code between 400 and 499. So I would recommend checking server-side logs, most probably you will be able to figure out what's wrong from them.

          2. It might be the case your ${access_code} variable is not defined, i.e. the relevant Post-Processor failed to extract it from the previous response. Double check it's value using Debug Sampler and View Results Tree listener combination


          3. It might be the case your ${access_code} variable contains some special characters which are not allowed in JSON and must be escaped





            • Backspace is replaced with b


            • Form feed is replaced with f


            • Newline is replaced with n


            • Carriage return is replaced with r


            • Tab is replaced with t


            • Double quote is replaced with "


            • Backslash is replaced with \


            If your ${access_code} variable contains any of the above - the resulting JSON will be incorrect. To be on the safe side I would recommend replacing your ${access_code} variable reference with __groovy() function call



            ${__groovy(org.apache.commons.lang3.StringEscapeUtils.escapeJson(vars.get('access_code')),)}


          4. It might be the case you're not sending a proper Content-Type header so make sure to add HTTP Header Manager and configure it to send application/json as the Content-Type







          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Nov 8 at 4:52









          Dmitri T

          67k33257




          67k33257












          • Thank you for the reply. I found that I am not receiving the access_code from the previous sampler. I am still going to replace the ${access_code} with the groovy function.
            – Harun Guna
            Nov 8 at 20:46


















          • Thank you for the reply. I found that I am not receiving the access_code from the previous sampler. I am still going to replace the ${access_code} with the groovy function.
            – Harun Guna
            Nov 8 at 20:46
















          Thank you for the reply. I found that I am not receiving the access_code from the previous sampler. I am still going to replace the ${access_code} with the groovy function.
          – Harun Guna
          Nov 8 at 20:46




          Thank you for the reply. I found that I am not receiving the access_code from the previous sampler. I am still going to replace the ${access_code} with the groovy function.
          – Harun Guna
          Nov 8 at 20:46


















          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%2f53200580%2fdynamic-entry-while-posting-a-json-body-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







          這個網誌中的熱門文章

          Tangent Lines Diagram Along Smooth Curve

          Yusuf al-Mu'taman ibn Hud

          Zucchini