Getting result of an http.request call

We are sending a https POST request using the call:

local request = {
url = address
type = “POST”,
verbose = true,
content_type = “application/json”,
data = data_json,
content_length = data_length,
fail_on_error = true,
handler = “HUB:the_plugin/scripts/utils/http_receive”
}

success, result = pcall(http.request, request)

The issue is we need to find out if the request was a success or not. The http_receive handler is being called, but with just an empty table as the parameter. I tried adding a http_connection_closed.lua handler, but it doesn’t appear to be called. I tried to subscribe to the http events via http.subscribe(), but that doesn’t appear to be a valid function.

Has anyone figured out how to do this?

To clarify, this is from a plugin running on the Ezlo sending https requests to an external server.

Hello @richK ,

I think this information would be very helpful for your request

Have a great reading! :nerd_face:

Thank you for your answer, but that thread is all about sending a http request TOO an Ezlo, not FROM an Ezlo. It doesn’t provide the answers we need.

Best Home Automation shopping experience. Shop at getvera!

© 2021 Ezlo Innovation, All Rights Reserved. Terms of Use | Privacy Policy | Forum Rules