Page 1 of 1

How to parse multiple json-variables in one Post?

Posted: Thu Aug 24, 2023 3:18 pm
by fingus
How to get this commandline working with Downloadfile?
curl -XPOST -H "Content-type: application/json" -d '{"apiVer": "1.0","command": "getAirconStat","deviceId": "1", "operatorId":"1","timestamp": 1659984520 }' 'http://192.168.10.168:51443/beaver/comm ... AirconStat'



I try different combinations of Customheaders and Post like this:
data$ = Downloadfile("http://192.168.10.168:51443/beaver/comm ... AirconStat", Post="{\"apiVer\": \"1.0\",\"command\": \"getAirconStat\",\"deviceId\": \"1\", \"operatorId\":\"1\",\"timestamp\": 1659984520 }")
print(data$)
WaitLeftMouse()
end
But get always errors. :(

Re: How to parse multiple json-variables in one Post?

Posted: Thu Aug 24, 2023 4:01 pm
by jPV
First of all, the second argument should be a table (you're missing {} around the post).

And then you should define PostType too, as you do with the header argument in curl.

Maybe this would work?

Code: Select all

data$ = Downloadfile("http://192.168.10.168:51443/beaver/command/getAirconStat", {Post="{\"apiVer\": \"1.0\",\"command\": \"getAirconStat\",\"deviceId\": \"1\", \"operatorId\":\"1\",\"timestamp\": 1659984520 }", PostType="application/json"})

Re: How to parse multiple json-variables in one Post?

Posted: Thu Aug 24, 2023 4:17 pm
by fingus
The response is "Not supported this command" which i get also with the wrong GET-Method.

Re: How to parse multiple json-variables in one Post?

Posted: Thu Aug 24, 2023 11:02 pm
by jPV
Hm... I don't know.. this seems to work fine:

Code: Select all

data$ = DownloadFile("http://ptsv3.com/t/hollyw/post/", {Post="{\"apiVer\": \"1.0\",\"command\": \"getAirconStat\",\"deviceId\": \"1\", \"operatorId\":\"1\",\"timestamp\": 1659984520}", PostType="application/json"})
DebugPrint(data$)
And the result is seen here
http://ptsv3.com/t/hollyw/