Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

How to pass or set null value in variable to post request

I’m posting HTTP request and JSR223 pre-processer to pass values like shown below,
Steps:

  1. HTTP post request reading values from JSR223 pre-proccesser
  2. Want to send null value for variable

JSR223 pre-processer :
vars.put("aptstatus","A")
vars.put("isccode",null)
I have used above way to pass value but in post request it is shown as

"status": "${aptstatus}",
"serviceCode": "${isccode}",

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

My requirement is to send null value in http post request.

Please help here how to set null value in variable.

Note: serviceCode is VARCHAR type

>Solution :

  1. In the JSR223 PreProcessor:

    vars.put("isccode", 'null')
    
  2. In the HTTP Request sampler:

    "status": "${aptstatus}", "serviceCode": ${isccode}
    

You will get:

"status": "A", "serviceCode": null

Demo:

enter image description here

More information on Groovy scripting in JMeter: Apache Groovy: What Is Groovy Used For?

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading