I sent the curl call from within the container to make sure everything works (connectivity, DNS, …)
I tried to convert this into an action in an automation:
alias: open Nuki via API
service: rest_command.axiom
data:
url: https://api.nuki.io/smartlock/XXX/action
method: POST
headers:
authorization: >-
Bearer
6XXXc
payload: |
{% set payload = {'action': 3} %} {{ payload | to_json }}
content_type: application/json
When running this action I get a “Action ran successfully” toaster but the command does not perform what it should.
The problem is that I have no way to debug it on the API side so before going into some crazy TLS proxification of the call to analyze it at the packet level I am hoping that there is an obvious error in my translation.
Notes:
I initially wrote authorization: Bearer 6XXXc in the headers section but due to the length of the token (I presume) the config was reformatted as per the above
there are no errors in the logs
EDIT: I realized I can use a simpler command, one that does not have a payload. Its translation is now:
url: https://api.nuki.io/smartlock/XXX/action/unlock
method: POST
headers:
authorization: >-
Bearer
6XXXc
Now this does not work at all, an error pops up with TypeError: Type is not JSON serializable: LoggingUndefined
I read the docs, of course, but thought that this was a generic definition of a service. Since I saw in my automation “RESTful Command: axiom” I religiously copied the information from the docs in the data section
Now it is clear, thank you again!
EDIT: as a side note I see that over the years there is less and less configuration done via configuration.yaml and I tend to forget that this is a place to consider as well when trying stuff.