Losant API Payload Breakdown

Trying to figure out the API params for “Device:Payload Counts Breakdown” but no matter what I put as the inputs for the start and end it always returns this same error message.

image

Ive tried differnet devices and swapping the start and end times nothing seems to work,

However using the exact same parameters I can get a response out of the “Device:Payload Counts”

Can you give us an example of something you are putting in for the start / end query parameters? Maybe show us the whole request?

The endpoint expects those values to be in milliseconds since Epoch; are you maybe providing seconds since Epoch?

Sure, here is the example values from the documentation plus some others and the results:

I only posted results once since they all responded the same

Well, the example from the documentation resolves to Monday, June 13, 2016 12:00:00 AM GMT-04:00, far more than 93 days ago.

Try going to epochconverter.com and generating a start and end timestamp for a start and end within the past 90 days (again, with milliseconds) and see if you get an expected result.

We do have a {{formatDate}} Handlebars helper that could be useful here; the format string for milliseconds since Epoch is ‘x’.

You may also find the Date/Time Node useful here.


yah that’ll do it, i was thinking about it wrong, i don’t know why i took it as “time in milliseconds back from current time at first”. Thanks for the quick responses like always, got it working!

We do support that - if you put a minus sign in front of the time. Combine that with “0” representing “now” and you can get pretty fancy.

For example, to return a device’s payload counts for the past 90 days (as of now), you could pass a start of -7776000000 and an end of 0.



like this?

Nevermind, that trick works for Device: Payload Counts but not Device: Payload Counts Breakdown. :thinking:

I’m going to file a ticket about that, especially since the Breakdown endpoint even lists a negative number as the default for the start value.

1 Like

Ok so im not crazy, I was definitely confused by that :melting_face: