Community Tip - Did you get called away in the middle of writing a post? Don't worry you can find your unfinished post later in the Drafts section of your profile page. X
Hi, I am trying to generate an output as a random number using Postman and I want to PUT this output value onto thing as a thing property value but
As in the official Mars Rover example used in the academic course, to change the 'WindSpeed' property using postman, the following syntax was used:
{
"WindSpeed" : "88"
}
But now I want to pass on the value of the "WindSpeed" in an automated manner (something like using the random value function) so that I don't have to manually change it every time,
Unfortunately, I am not able to do so as I have trying ways available online including setting global variables etc. etc. but it is always giving an error of 'BAD STRING' or that the JSON content does not have 'ValidProperties' etc. I think that maybe my syntax is wrong. Could someone please guide me as to how we can generate random values in postman(syntax etc.) and PUT it onto the thing so that it updates itself.
Thanks!
Solved! Go to Solution.
Hi Tushar Yadav,
Please try the below alternative method to set a random number for a property:
Hi Tushar Yadav,
Have you tried the below format?
var x = Math.floor((Math.random() * 100));
WindSpeed : x
Hi Yamini,
Yes, I did try it like this but it shows error. I am attaching the screenshot for your reference.
Hi Tushar Yadav,
Please try the below alternative method to set a random number for a property:
Hi Yamini,
Yes, this works.
Thanks for the solution!
Hi Tushar Yadav,
Glad to know that it helped!