Page 1 of 1

Simple HTTP GET?

Posted: Wed May 11, 2016 1:11 am
by danmiles86
I'm having some trouble with what I thought would be simple! I just need a script for my router to connect to my home automation to power cycle some devices as required. It just needs to open a link in the form off the following;

http://192.168.20.11:3480/data_request? ... getValue=0

I've tried a few things like;

/tool fetch url="http://192.168.20.11:3480/data_request? ... ormat=json"

/tool fetch address=192.168.20.11 src-path=data_request?id=action&DeviceNum=113&serviceId=urn:upnp-org:serviceId:SwitchPower1&action=SetTarget&newTargetValue=0 port=3480 mode=http

But keep getting various errors, mainly failed (6).

I don't need to keep the returned XML file, just as long as the GET request has gone through. I'm hoping to use the script in Netwatch Down.

Re: Simple HTTP GET?

Posted: Wed May 11, 2016 3:10 am
by boen_robot
You need to escape the "?", as it triggers the help, and in turn doesn't get added to the URL, causing a wrong URL to be called, in turn causing a 404, in turn causing the error message.

i.e. use
/tool fetch url="http://192.168.20.11:3480/data_request\?id=action&DeviceNum=113&serviceId=urn:upnp-org:serviceId:SwitchPower1&action=SetTarget&newTargetValue=0&output_format=json"

Re: Simple HTTP GET?

Posted: Wed May 11, 2016 12:48 pm
by danmiles86
Thank you, thank you, thank you! I wansn't even thinking of this as a possibility and I would have been hours stressing over this. Worked first time. :D

I don't suppose you also know how I can modify this so it doesn't save the file or automatically deletes it?

Re: Simple HTTP GET?

Posted: Wed May 11, 2016 8:48 pm
by boen_robot
/tool fetch url="http://192.168.20.11:3480/data_request\?id=action&DeviceNum=113&serviceId=urn:upnp-org:serviceId:SwitchPower1&action=SetTarget&newTargetValue=0&output_format=json" keep-result=no
(notice that last part)

Re: Simple HTTP GET?

Posted: Thu May 12, 2016 12:58 am
by jeroenp
Just in case you ever need it, a list of escapes is in the scripting language manual.

Re: Simple HTTP GET?

Posted: Thu May 12, 2016 2:09 am
by danmiles86
Thank you. Sorry the second part was simple and should have got that myself. Very much appreciate the help.