Node to export payload to pc

I was wondering if there is a feature, such as a workflow node, which can either:

  • export payload to a folder on my pc. That way I can make my Java program look through that folder every few minutes to find new exported files to read.


  • Allow my program to access my Losant devices and retrieve payload data from every few minutes.

The easiest approach will be for your program to request the required data from the Losant API.

To get device data every few minutes, you could use last-value-query or time-series-query.

We don’t yet have a Java client (working on it), but the API is pretty easy to request directly.

Unfortunately it won’t be possible for the workflow to directly write data to a local folder. This is because the logic all runs server-side and browser security won’t allow us to write data like that to the local file system.

It looks like you may have accidentally googled the url instead of visiting the url (the page you described is the google page when nothing is found). It looks to me like you are missing a colon in the url - you put in https// instead of https:// - and I bet your browser assumed it was something to google instead of a web page to visit.

However, even if you fix that, you would not get what you expect in the browser - since that API endpoint expects a POST and not a GET request.

I would recommend reading the REST API overview documentation, and possibly using a tool like curl (if you are comfortable on the command line) or Postman (if you would prefer a GUI) to experiment with accessing our API.


I see you’re trying to use the API to query this data. However, I’m wondering if you even need to use the REST API. Could you provide more information about what you’re trying to accomplish?

If you’re comfortable in the Workflow Engine, I’d recommend checking out this node:

With it, you can easily query the last attribute value for your devices.

I have a couple of applications in mind. The first I’m trying out is an building ambient monitor where sensor 1 will be uploading data to Losant, while a second device (in a remote location) will pull data from it, displaying it on an OLED display.

This is why I’m trying to use the REST API. I’ve tried Workflow and it works, however the intent is not to use a computer just to view the readings via Dashboard.

Another application I have in mind is for remote control of PLC I/O for automation. Same principle. One would be a transmitter, one would be a receiver.

Ah yes. If you’re devices are connect with MQTT, these are great uses for Device Commands:

With Device commands, you can use the Workflow Engine to send data back down to your device.

I still want to be able to use the ‘last-value-query’ rest API. There are many scenarios I would like to use it for.but right now, it’s just not working for me. I was hoping one of you guys can help out with the information I already shared.


What are you currently sending as the body of the post request? If you look at the docs for that endpoint, you can see how it talks about an example body, and links to the schema for the body of that request.

In your case, based on what you have said, I’m guessing that you would want the request body to be something like:

  "deviceIds": [ "YOUR_DEVICE_ID_HERE" ],

Also, don’t forget to set the Content-Type header in Postman to application/json (we talk about that more here in the docs).

Thanks for pointing me to the right direction. I added the 'bodyb based on ‘last-value-query’ schema, added the headers and voila! . Postman was happy and returned expected value for Temperature. That’s one piece of the puzzle done.

The next challenge I have is making it work on the Arduino IDE side. After supplying the necessary headers and data, httpCode being returned is always -1 (Connection_Refused). I’m currently stuck at this junction.

Not sure if you can help me on this one but I posted anyway because you might have an insight.

The code snippet is below:

void loop() {
String strDATA = “{” + Q + “deviceIds” + Q + “:[” + Q + “5e2c898b322a8f0006e3f580” + Q + “],” + Q + “attribute” + Q + “:” + Q + “Temperature” + Q + “}”;

Serial.print("\nHTTP.POST JSON Data: "); 

char *host = "" ;  //Web Server address to read/write from

HTTPClient http;    //Declare object of class HTTPClient 

http.begin(host);   //Specify request destination 
http.addHeader("Content-Type", "application/json");    //Specify content-type header 
http.addHeader("Accept", "application/json");        
http.addHeader("Authorization", "Bearer myApplication_ID");    

int httpCode = http.POST(strDATA);  //Send the request 

String payload = http.getString();    //Get the response payload