Search code examples
jmeter

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.

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