OpenURL HTTP postdata string behaviours with Tibber API
Posted: Tuesday 07 October 2025 10:08
I'm using the OpenURL postdata string to send a GraphQL command to the Tibber API.
Tibber has a developer site https://developer.tibber.com/explorer where you can test if the postdata string is correct, that is, produces JSON result.
I come across that a GraphQL command in de tibber developer works but with the OpenURL returns no data.
This is the GraphQL command, this works in the developer site and returns JSON data:
{viewer{homes{consumption(resolution:DAILY,last: 31 ,after:"MjAyNS0wOS0wMQ" ){nodes{from cost unitPrice consumption}}}}}
This is the postData, which returns no data in Domoticz:
postData = '{"query": "{viewer{homes{consumption(resolution:DAILY,last: 31 ,after:"MjAyNS0wOS0wMQ" ){nodes{from cost unitPrice consumption}}}}}"}'
The OpenURL is:
dz.openURL({
url = endpointTibberAPI,
method = 'POST',
callback = scriptVar,
headers = {
['Content-Type'] = 'application/json',
['Authorization'] = 'Bearer ' .. accessTokenTibber
},
postData = <the above string with a valid GraphQL command>
})
The item.data section returns : RAW response data "item.data" was {"error":"syntax error"}
Again: when copy/past this GraphQL string in the tibber developer tool, I get NO error!
Note: when I remove the part with the quotes in the postData is works with OpenURL! That is, is returns JSON data.
E.g postData = '{"query": "{viewer{homes{consumption(resolution:DAILY,last: 31 ){nodes{from cost unitPrice consumption}}}}}"}'
(of course I have to remove the section (,after....) to have a clear GraphQL statement)
I suspect that DzVents does "something" with the postData string before is is executed, where the double quotes in the postData mess up the GraphQL string.
But I can't see this, when I set log-info to debug, domoticz shows the same string as I put in postData.
What can cause this? How can I debug the url which is sent by domoticz to this (any) API?
Tibber has a developer site https://developer.tibber.com/explorer where you can test if the postdata string is correct, that is, produces JSON result.
I come across that a GraphQL command in de tibber developer works but with the OpenURL returns no data.
This is the GraphQL command, this works in the developer site and returns JSON data:
{viewer{homes{consumption(resolution:DAILY,last: 31 ,after:"MjAyNS0wOS0wMQ" ){nodes{from cost unitPrice consumption}}}}}
This is the postData, which returns no data in Domoticz:
postData = '{"query": "{viewer{homes{consumption(resolution:DAILY,last: 31 ,after:"MjAyNS0wOS0wMQ" ){nodes{from cost unitPrice consumption}}}}}"}'
The OpenURL is:
dz.openURL({
url = endpointTibberAPI,
method = 'POST',
callback = scriptVar,
headers = {
['Content-Type'] = 'application/json',
['Authorization'] = 'Bearer ' .. accessTokenTibber
},
postData = <the above string with a valid GraphQL command>
})
The item.data section returns : RAW response data "item.data" was {"error":"syntax error"}
Again: when copy/past this GraphQL string in the tibber developer tool, I get NO error!
Note: when I remove the part with the quotes in the postData is works with OpenURL! That is, is returns JSON data.
E.g postData = '{"query": "{viewer{homes{consumption(resolution:DAILY,last: 31 ){nodes{from cost unitPrice consumption}}}}}"}'
(of course I have to remove the section (,after....) to have a clear GraphQL statement)
I suspect that DzVents does "something" with the postData string before is is executed, where the double quotes in the postData mess up the GraphQL string.
But I can't see this, when I set log-info to debug, domoticz shows the same string as I put in postData.
What can cause this? How can I debug the url which is sent by domoticz to this (any) API?