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

Variable in the request is used without quotes. How to turn it into a string?

Consider the following scenario:

  1. Request 1 gets a JSON response. Then, JSON extractor retrieves a particular id from the response JSON and assigns it to a variable.
  2. Request 2 posts that variable inside a JSON for further processing.

Request 2 body is sent as follows:
{"orderId": 6f2ce33a-0594-47c5-5053-a13f5cf7ef33, "price": "1234"}

But I need the orderId to be sent as string, otherwise server returns 500.

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

I have come across a potential solution, namely String.valueOf(i), but I do not know WHERE and HOW to apply it in JMeter, and if it even is what I need. Any help is much appreciated.

  • Please bear in mind I am very green when it comes to JMeter.

>Solution :

I assume that the correlated value is cOrderId

so, all you need to do in your request 2 is to pass the variable with quotes

something like

 {"orderId": "${cOrderId}", "price": "1234"}
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