GeoBau
(Geo Bau)
June 17, 2024, 7:50pm
1
I have a problem with the payload.
askoheater_ein:
url: https://cloud.solar-manager.ch/v1/control/water-heater/6363b8896ed917....
method: PUT
headers:
accept: "application/json"
Authorization: Bearer {{ states('sensor.sm_accesstoken') }}
payload: >
"{'waterHeaterMode': 1,'powerSettingPercent': {{ states('number.id3_battery_target_charge_level') }} }"
content_type: "application/json"
the result is
content:
statusCode: 400
error: Bad Request
message: Invalid request payload input
status: 400
where is my mistake??
tom_l
June 18, 2024, 4:15am
2
No capital letter for “authorization” in the header. Also, get in the habit of quoting your single line templates. It wasn’t required in this case as your template started with a string, but it is best practice.
headers:
accept: "application/json"
authorization: "Bearer {{ states('sensor.sm_accesstoken') }}"
GeoBau
(Geo Bau)
June 18, 2024, 5:10am
3
thanks for the hint. I will change it.
in the meanwhile I reduced my issue.
my issue is that it works in swagger:
curl -X 'PUT' \
'https://cloud.solar-manager.ch/v1/control/water-heater/6363b8896ed9175aff18df72' \
-H 'accept: application/json' \
-H 'Authorization: eyJhbGci....c' \
-H 'Content-Type: application/json' \
-d '{
"waterHeaterMode": 1,
"powerSettingPercent": 20
}'
but in restful it is not working:
askoheater_ein:
url: https://cloud.solar-manager.ch/v1/control/water-heater/6363b8896ed9175aff18df72
method: PUT
headers:
accept: "application/json"
Authorization: "Bearer {{ states('sensor.sm_accesstoken') }}"
payload: >
"{'waterHeaterMode': 1,'powerSettingPercent': 20}"
content_type: "application/json"
it results in an error
content:
statusCode: 400
error: Bad Request
message: Invalid request payload input
status: 400
the autorization is probably ok (switching off in rest_command with “{‘waterHeaterMode’: 2,‘powerSettingPercent’: 0}” works.
Where is my mistake?
GeoBau
(Geo Bau)
June 18, 2024, 5:25am
4
this chatgpt gives me the solution
askoheater_ein:
url: https://cloud.solar-manager.ch/v1/control/water-heater/6363b8896ed9175aff18df72
method: PUT
headers:
accept: "application/json"
Authorization: "Bearer {{ states('sensor.sm_accesstoken') }}"
payload: >
{
"waterHeaterMode": 1,
"powerSettingPercent": 20
}
content_type: "application/json"