You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi there, I've been struggling to get rest_command to work when using x-api-key in a POST operation. After many hours of searching and trying many different combinations, I finally found a solution, and would like to suggest an additional example for the documentation that might help others avoid the frustration I went through !
I found the only way to get x-api-key to work was to store it in the secrets file. Once I did this the API call worked. My code looks like this:
powervault_set_override_status:
url: "https://api.p3.powervault.co.uk/v3/unit/<unitID>/stateOverride"
method: post
headers:
x-api-key: !secret powervault #name of the entry in the secrets.yaml file
accept: "application/json"
user-agent: 'Mozilla/5.0'
content_type: 'application/json; charset=utf-8'
payload:
'{"stateOverrides": [ {"start": "{{ start_time }}",
"end": "{{ end_time }}",
"state": "{{ new_state }}" } ] }'
It was also frustrating that I couldn't see what data was actually being sent to the API endpoint, even when I enabled debug logging it never showed the full request, specifically the headers. As I had to pass x-api-key in the header, I was unable to see if it was being formatted correctly. The API provider documented how it should appear, inlcuding examples using curl, but without being able to see what was being sent, I was guessing as to which part was wrong. I have seen posts from other people struggling with the same challenge. Apologies if this should be raised as a separate issue?
Hey there @jpbede, mind taking a look at this feedback as it has been labeled with an integration (rest_command) you are listed as a code owner for? Thanks!
Code owner commands
Code owners of rest_command can trigger bot actions by commenting:
@home-assistant close Closes the feedback.
@home-assistant rename Awesome new title Renames the feedback.
@home-assistant reopen Reopen the feedback.
@home-assistant unassign rest_command Removes the current integration label and assignees on the feedback, add the integration domain after the command.
@home-assistant add-label needs-more-information Add a label (needs-more-information) to the feedback.
@home-assistant remove-label needs-more-information Remove a label (needs-more-information) on the feedback.
There hasn't been any activity on this issue recently. Due to the high number of incoming GitHub notifications, we have to clean some of the old issues, as many of them have already been resolved.
If this issue is still relevant, please let us know by leaving a comment 👍
This issue has now has been marked as stale and will be closed if no further activity occurs. Thank you for your contributions.
Feedback
Hi there, I've been struggling to get rest_command to work when using x-api-key in a POST operation. After many hours of searching and trying many different combinations, I finally found a solution, and would like to suggest an additional example for the documentation that might help others avoid the frustration I went through !
I found the only way to get x-api-key to work was to store it in the secrets file. Once I did this the API call worked. My code looks like this:
It was also frustrating that I couldn't see what data was actually being sent to the API endpoint, even when I enabled debug logging it never showed the full request, specifically the headers. As I had to pass x-api-key in the header, I was unable to see if it was being formatted correctly. The API provider documented how it should appear, inlcuding examples using curl, but without being able to see what was being sent, I was guessing as to which part was wrong. I have seen posts from other people struggling with the same challenge. Apologies if this should be raised as a separate issue?
URL
https://www.home-assistant.io/integrations/rest_command/
Version
2025.2.5
Additional information
No response
The text was updated successfully, but these errors were encountered: