"Query has additional properties" despite checking schema

Hi,

I’m trying to use the Losant API node to perform a time-series query. I’m working from the time-series query schema described here:

However, I’m getting the “query has additional parameters” response from the Losant API node when I test the workflow using the Virtual Button.

Here’s the exact JSON passed by the Virtual Button:

{
	"aggregation": "NONE",
	"attributes": [
		"FLOW_MLMIN",
		"PRESS_KPA",
		"FLOW_C",
		"BATT_V",
		"COMM_C"
	],
	"deviceIds": [
		"5ceed97a4c33040007a6cccd"
	],
	"start":1558807352,
	"end":1559239352,
	"duration":0,
	"resolution":0,
	"deviceTags":[]
}

I’m not sure where the additional parameters are coming from. I saw a bug-report where a different Losant API function was giving the same error response, but in that case, it seems like it was a bug in the endpoint on Losant’s end. I’m not sure if it’s the same issue here, or if I’m doing something incorrectly.

Hi @Alexander_Farley,

I will test this out and see if I can locate a problem. I will get back to you shortly!

Thanks,
Julia

Hi @Alexander_Farley,

It looks as though this issue is arising as the full schema has been put into the JSON template for the Losant API Node. By putting the JSON in the Virtual Button, you are putting them on the payload, so they would need to be referenced with {{data.body.variableNameHere}}. The JSON you have above can also be put directly into the Losant API Node, which should then operate as expected:

Let me know if this solves it!

Thanks,
Julia

Thanks Julia - I’m almost there, but I have one point of confusion.

I’m using this JSON in the Virtual Button:

{
    "deviceId":"5ceed97a4c33040007a6cccd",
  	"start":1559014432000,
  	"end":1559273632000
}

And I’ve found that I have to use this in the Losant API node for the query to provide a good response:

{
	"aggregation": "NONE",
	"attributes": [
		"PRESS_KPA"
	],
	"deviceIds": [
    {{data.body.deviceId}}
	],
	"start":{{data.start}},
	"end":{{data.end}}
}

Why is it that I can access the variable start using {{data.start}} but I need to use {{data.body.deviceId}} to get the deviceId? It would make more sense to me if the deviceId was available at {{data.deviceId}}.

It seems like I’m misunderstanding how the JSON payload coming from the Virtual Button is inserted into the payload as received by the Losant API.

To be clear: I am getting

InvalidJsonError
Param query template did not render to valid JSON

When I use {{data.deviceId}} instead of {{data.body.deviceId}, even though the debug window seems to show data.deviceId populated with the expected value.

Looks like I figured this one out - the documentation states “Any string value being output by a string template should be wrapped in double quotes”. So I wrapped {{data.deviceId}} with quotes and now it works.

Thanks for the assistance!

1 Like