0

Problem sending an Http Post Request

koen Brants 1 year ago in Devices / Http updated 1 year ago 2

Hello,

I want to send an HTTP call to my home assistant server. 

The idea is to connect my doorbell to my sound system. 

Running the command get's me the following log line

Devices : 26/03/2023 17:41:17 : Error : Tasks\Test : Error calling HttpRequest. The remote server returned an error: (405) Method Not Allowed. at System.Net.HttpWebRequest.GetResponseFromData (System.Net.WebResponseStream stream, System.Threading.CancellationToken cancellationToken) 0x00146 in <9bd67acb7e9448b0ae17ea9ad68db84f>:0
at System.Net.HttpWebRequest.RunWithTimeoutWorkerT (System.Threading.Tasks.Task`1TResult workerTask, System.Int32 timeout, System.Action abort, System.Func`1TResult aborted, System.Threading.CancellationTokenSource cts) 0x000f8 in <9bd67acb7e9448b0ae17ea9ad68db84f>:0
at System.Net.HttpWebRequest.GetResponse () 0x00016 in <9bd67acb7e9448b0ae17ea9ad68db84f>:0
at ComfortClick.Tasks.TaskCommands.HttpRequest.Get () 0x0006c in <0e0f871ce2a547fdb865117a9a4f9ea3>:0


It seems that this occurs when it 's a GET request, while the server requires POST.


So I tried with curl : 

Running the following command line on my laptop : 

curl -X POST http://192.168.0.88:8123/api/webhook/startdoorbell

-> works OK

curl http://192.168.0.88:8123/api/webhook/startdoorbell

-> ERROR:  405: Method Not Allowed (Home Assistant refuses the GET requests)

-> Same error as logged by comfortclicks http request ...


Any ideas ?



+2

Hello,

I've conducted a small test, and in my case it's working. I had to make some small changes according to what I've found on the HA documentation, because initially it was not working:

Http driver configuration:

Image 4525

Http command configuration:

Image 4528


Please note the post data...

I was not getting any error on ComfortClick, but the webhook was not being executed at all. After looking in the HA webhook documentation, I've found that indication of the key value, so I test it and it worked.

Best regards

Thanks Ricardo ! 

I'll try this asap. 

Best Regards,

Koen