Getting an Integer from a property in REST request body
Hi,
I have two rest requests, and I want to use a part of the response from one in the request of the other.
however, the second one takes an integer in the body, and the only way to set properties is AFAIK setPropertyValue(string, string).
if I use this I get this as a response
{
"internalStatus": "Bad Request",
"invalidValue": "{#Project#polnr}",
"message": "An element has an incorrect datatype"
}
Is there a way to get an integer into the rest request body? I've looked everywhere and it looks like it's impossible, but it seems like such a small and easy thing.
As {#Project#polnr} is noticed, assuming that a custom Project property value is being used.
the only way to set properties is AFAIK setPropertyValue(string, string).Yes, they always store the values in string format.
Is there a way to get an integer into the rest request body? I've looked everywhere and it looks like it's impossible, but it seems like such a small and easy thing.Yes, it is indeed possible.
Here is the sample JSON payload which demonstrate how to use both string, and number respectively using the same project property named "ABC" with the value 10
{ "value" : "${#Project#ABC}" "number" : ${= (context.testCase.testSuite.project.getPropertyValue('ABC') as int)} }
And here is the snapshot of RAW request for the above.
So, you can use in the similar fashion, just use your property.
May be, "number" : ${#Project#ABC} might also works (note no quotes around the value), please check it out.