How to parse multiple json-variables in one Post?

Discuss any general programming issues here
Post Reply
User avatar
fingus
Posts: 269
Joined: Fri Sep 16, 2011 9:53 am

How to parse multiple json-variables in one Post?

Post 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. :(
User avatar
jPV
Posts: 604
Joined: Sat Mar 26, 2016 10:44 am
Location: RNO
Contact:

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

Post 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"})
User avatar
fingus
Posts: 269
Joined: Fri Sep 16, 2011 9:53 am

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

Post by fingus »

The response is "Not supported this command" which i get also with the wrong GET-Method.
User avatar
jPV
Posts: 604
Joined: Sat Mar 26, 2016 10:44 am
Location: RNO
Contact:

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

Post 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/
Post Reply