OpenWeather - openURL postData surrounded by square brackets

Easy to use, 100% Lua-based event scripting framework.

Moderator: leecollings

Post Reply
IanDury
Posts: 47
Joined: Wednesday 08 April 2015 15:22
Target OS: Linux
Domoticz version: Beta
Location: Netherlands
Contact:

OpenWeather - openURL postData surrounded by square brackets

Post by IanDury »

I would like to upload my weather station data to OpenWeather using openURL postData but I wonder if this is possible with the OpenWeather API where square brackets are used. The following example works when using curl:

Code: Select all

curl -X POST -H "Content-Type: application/json" http://api.openweathermap.org/data/3.0/measurements?appid=1234abc -d '[{"station_id":"121314a","dt":1606139843,"temperature":8.500000}]'
Using openURL:

Code: Select all

domoticz.openURL({
                url = 'http://api.openweathermap.org/data/3.0/measurements?appid=1234abc',
                method = 'POST',
                callback = 'owm_callback',
                postData = {station_id = "121314a", dt = 1606139843, temperature =8.500000}
                )}
Results with this response from OpenWeather because the surrounding square brackets are missing:

2022-05-15 23:31:44.328 Status: dzVents: Debug: OWM: {"code":400001,"message":"unmarshal type error: expected=[]types.MeasurementRequest, got=object, offset=1"}

I could use curl with os.execute but I prefer to use openURL. Anyway to get the square brackets surrounding the postData?
Post Reply

Who is online

Users browsing this forum: Amazon [Bot] and 1 guest