REST API Export Problem

I’m having trouble getting control of the REST api export command. The best I can do based on the example on is to get data sent to my email using the following Curl example (the token and id strings are disguised). Unfortunately, I cannot get it to recognize the start and end times. It sends all of my data, no matter what I do.

I’ve also tried implementing this using Electric Imp agent code, with similar results. Any tips or examples would be much appreciated.

curl -H ‘Content-Type: application/json’
-H ‘Accept: application/json’
-H 'Authorization: Bearer eyJhbGciOiJIUzI1… YOUR_API_ACCESS_TOKEN …k-wgdGW1szQM’
-d ‘{“start”:-3600,“end”:0}’
-X POST… APPLICATION_ID …68b814/devices/5c282a… DEVICE_ID …043873/export?

Hello @Frank_Braswell!

I was able to replicate this problem and find a solution! The cURL documentation states that “options and their parameters must be specified on the same line in the file, separated by whitespace, colon, or the equals sign.” Thus, since we are specifying the email in the URL, all of the parameters must also be in the URL. Calling them separately with -d must be causing them to be ignored.

Here is the cURL syntax with the parameters in the URL:

curl -H 'Content-Type: application/json' \
    -H 'Accept: application/json' \
    -H 'Authorization: Bearer YOUR_API_ACCESS_TOKEN' \
    -X POST \

One more quick note: I set my start value to -360000 (6 minutes), as my device only updates once a minute.

Let me know if this works!

Hi Julia,

I still can’t get it to recognize the start and end parameters. Below is the transaction on my Mac terminal.

Thanks so much for your prompt response! - Frank

Franks-iMac:~ frankbraswell$ curl -H 'Content-Type: application/json' \
-H 'Accept: application/json' \
-H 'Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXxxxxxxxxxxI4icqoBgqDaWgo_k-wgdGW1szQM' \
[1] 10271
[2] 10272
Franks-iMac:~ frankbraswell$ {"success":true}
[1]-  Done                   
curl -H 'Content-Type: application/json' -H 'Accept: application/json' -H 'Authorization: Bearer xxxxxxxxxxxxxxVhZjkxM_k-wgdGW1szQM' -X POST
[2]+  Done                    start=-360000
Franks-iMac:~ frankbraswell$ 

–First Line of data

–Last line of data

Hi Frank!

I am trying to replicate this problem to better assist. :grinning:

Could you post a screenshot of the attachment that is being sent to your email? Here is mine:


Hi Julia,

Can you get the information from the email link? I also uploaded the screenshot. Did it come through?



Your data export for device ElectricImpDeviceLive is now ready. To download the export, please click the following URL or copy and paste it into your browser:

Thanks for using Losant!
The Losant Team

1 Like

Hello @Frank_Braswell,

I have been playing with this trying to replicate, but have not done so successfully. However, I have some resources for debugging and testing. There are multiple ways to export device data, so I am curious as to which will work successfully for you. Here are a couple of things to try:

This we have attempted, but not been able to limit successfully. Here is a screenshot of my terminal:

Postman is a tool that can be used for POST requests, and will format the request for you, you just have to fill out the parameters. I would be curious to see what would come through to your email when using Postman. Here is an example of mine:

Losant API Device Export
The Losant API Node has a Device Export Resource that can be easily configured within a workflow. You can also test with this one to see if it recognizes the start and end values.

Let me know if any of these work!

Hi Julia,

I have the answer to the problem. After looking closely at your url, I noticed that the punctuation characters were escaped with a backslash:


The url below is what was giving us trouble:


I’m not sure why it even recognized the email, but it only does if it is the first thing after the “?”. I’m also not sure why I was having trouble with the Electric Imp request, but it seems to be working now. Perhaps I was feeding it a positive 360000 instead of a negative 360000.

Turns out the Postman app must take care of the special characters for us, so it isn’t a problem. (Thanks for recommending Postman! I think it will come in handy for lots of things.)

I really appreciate your help and patience!


1 Like