Have a custom app to do certain things. Wanting to add a reboot command in the app. I know I use 'http://IP:8080/hub/reboot.
Can't quite figure out how to implement the code for this. Someone give me a suggestion please.
Have a custom app to do certain things. Wanting to add a reboot command in the app. I know I use 'http://IP:8080/hub/reboot.
Can't quite figure out how to implement the code for this. Someone give me a suggestion please.
void asynchttpPost(String callbackMethod = null, Map params, Map data = null)
void httpPost(String uri, String body, Closure closure)
void httpPost(Map params, Closure closure)
Well, that's what I looked at, but can't quite get the syntax right I guess.
Is it something like this:
httpPost( "192.168.1.171/hub/reboot")
Or do I need to separate things out?
Close, need to give it a place to analyze the response even if you do nothing, i.e.
if(security) cookie = getCookie()
httpPost(
[
uri: "http://192.168.1.171:8080",
path: "/hub/reboot",
headers:[
"Cookie": cookie
]
]
) { resp -> }
It was the response part that was tripping me up.
Thanks,
To follow up on this, I got it working using the code you suggested.
What I don't understand, Why do I need the cookie? I don't have security on the hub.
If I understand this code is using a map. Isn't there a way to just do a one line in the manner of:
void httpPost(String uri, String body, Closure closure)
No biggy, just trying to understand it.
Cookie is only needed if you have security enabled. As to the syntax, should be able to, I just have never coded it that way so no examples.
I tried this without the cookie stuff and it gave me an error. Tried leaving the headers part out and also got an error.
httpPost(
[
uri: "http://192.168.1.171:8080",
path: "/hub/shutdown",
headers:[
]
]
) { resp -> }
Tried this and got error:
httpPost("http://192.168.1.171:8080", "/hub/reboot") { resp -> }
Same with this:
httpPost("http://192.168.1.171:8080", "/hub/reboot", response())
I did create a routine called response.
And other variations on the same thing.
maybe
httpPost("http://192.168.1.171:8080", "/hub/reboot", httpResponse)
...
Closure httpResponse() {
...
}
NAH. Tried various different ways on the above and doesn't work.
Don't worry about it, it works ok the other way, so I'll use that.
Thanks for the time.
This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.