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 in IoT (Internet of Things) by Shubham
• 13,290 points
297 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 by Upasana
• 8,530 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,260 points
71 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,100 points
39 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 in IoT (Internet of Things) by Upasana
• 8,530 points
460 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,060 points
69 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,100 points
74 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,530 points
261 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,530 points
152 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 23, 2018 in IoT (Internet of Things) by Upasana
• 8,530 points
37 views