Postman Generating an output as a random number

0 votes

So I'm using the Postman so that I can PUT it onto a 'thing' in my IoT app, by generating an output as a random number.

If I use the following format, it works okay:

{

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

But I've failed in doing so. I have been trying ways including but not limited to setting global variables etc. etc. but it throws an error of 'BAD STRING' or that the JSON content does not have 'ValidProperties' etc.

Can anyone please help me out?

Thanks!

Feb 12, 2019 in IoT (Internet of Things) by Shubham
• 13,490 points
5,869 views

1 answer to this question.

0 votes

Try generating your random value in the prescript tab using a function like this one:

// random generator function
        function getRandomInt(min, max) {
        min = Math.ceil(min);
        max = Math.floor(max);
        return Math.floor(Math.random() * (max - min)) + min;
        }
// generate the random value
var myval = getRandomInt(0,100)
// set the value into the global variable
postman.setGlobalVariable("value",myval)

// to see it in console
console.log(myval)

Then, in your JSON body, you can go ahead with the following.

{
    "Windspeed":{{value}}
}

This should work just fine.

answered Feb 12, 2019 by Upasana
• 8,620 points

Related Questions In IoT (Internet of Things)

0 votes
1 answer
0 votes
1 answer

Using FIWARE to start Cygnus as a Service in IoT Solution

Cygnus is supposed to create /var/run/cygnus/ when started. You ...READ MORE

answered Aug 13, 2018 in IoT (Internet of Things) by anonymous2
• 4,280 points
756 views
0 votes
1 answer

Running a childProcess as shell script with node.js server

Here's what I think, you could pass ...READ MORE

answered Aug 14, 2018 in IoT (Internet of Things) by DataKing99
• 8,240 points
526 views
0 votes
1 answer

Postman: Error “Unsupported Media Type” for send notification

Postman Check this link out. or maybe schemas any field ...READ MORE

answered Apr 29, 2019 in IoT (Internet of Things) by Upasana
• 8,620 points
17,716 views
0 votes
1 answer

Displaying Table Schema using Power BI with Azure IoT Hub

Answering your first question, Event Hubs are ...READ MORE

answered Aug 1, 2018 in IoT (Internet of Things) by nirvana
• 3,130 points
1,026 views
0 votes
1 answer

How to use the data I receive from Azure IoT Hub?

The payload you receive will be a ...READ MORE

answered Aug 1, 2018 in IoT (Internet of Things) by DataKing99
• 8,240 points
1,628 views
0 votes
1 answer

Failure of JSON parsing in Arduino and ESP8266

I'm assuming it's because of the garbage ...READ MORE

answered Dec 24, 2018 in IoT (Internet of Things) by Upasana
• 8,620 points
2,522 views
0 votes
1 answer

How to deploy Windows 10 IoT (Rasp Pi image) as a Virtual Machine

The easiest way I found is downloading ...READ MORE

answered Sep 10, 2018 in IoT (Internet of Things) by Upasana
• 8,620 points
2,951 views
0 votes
1 answer

What is the time taken by a 200 byte message for transmission in a beacon-enabled network?

Now, data rates of IEEE 802.15.4 are ...READ MORE

answered Aug 24, 2018 in IoT (Internet of Things) by Upasana
• 8,620 points
648 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP