Https post hubaction


I need t send hubaction command with HTTPS POST method.

I 've modified one of my working codes to https as following. But I see no packets going out from the Hub to the destination.
What am I missing ?

	def host = ""
    def method = "POST"
    def path = "/v1/say_text"   
    def headers = [:] 
    headers.put("HOST", "$host")
    headers.put("content-type", "application/json")
    headers.put("Authorization", "Bearer $state.token")
    try {
    def body="""{"text": "Pizza","use_vector_voice": true,"duration_scalar": 1.0}"""

    def hubAction = new physicalgraph.device.HubAction(
    	method: method,
    	path: path,
    	headers: headers,
        body: body
    catch (Exception e) {
    	log.debug "Hit Exception $e on $hubAction"


is the destination on the same network as the hub?

yes. destination is and the hub is

I don’t believe that it supports HTTPS requests. Where is it going to get the certificate?

what do you mean by “it” ?
Hub ?
I’ve seen examples of Hubaction command to port 443
so if it is not https , why port 443 ?
besides, I don’t want to use any client side certificates.

All I know is that they aren’t supported, as you can see by the other thread i linked to. Maybe try searching the forum for HTTPS, there are a lot of threads on it.

1 Like

well, I really don’t understand.
because when I use a httppost command to an external REST API with https , I receive the correct answer.
so , we can call https for external calls.

now, I also need to send a call to internal IP from the HUB.
if you say that HUB can not handle https, I can understand it.

but currently I am not able to see packet to the https server with the code sample I’ve written.
first, I have to figure out what’s missing there , and see that the packet is going to the correct destination.
then, if it does not support https , I will be stuck.

You new to convert the ip and port to Hex. See this doc for examples:

I don’t see a sendHubCommand() to actually run the HubAction you defined. Is the hubAction line effectively the last line of a command method and so acting like a return hubAction to get Smart things to run it for you?

You can send it in hex if you like but you don’t have to.

What the document doesn’t tell you is that they allow for you already having set the device network ID to the hex IP and port format so parse will get responses and they are using that as a fallback source of the host address and port. They are actually converting it from hex before using it in the host header though.

in my previous experience, I did not use sendHubActionCommand() and it did work.
Now I tried both ways but neither was successful.
Packets don’t go out …
how can I troubleshoot further ?