SwitchBotAPI
SwitchBotAPI copied to clipboard
Authorization Headers work with GET, but not POST
Current Situation
I am a beginner when it comes to working with APIs. I am attempting to set a Lock's state via a POST request. I'm able to request its status with GET, which returns 100, but as soon as I try to POST to the same resource, I receive the following error:
Authorization header requires 'Credential' parameter. Authorization header requires 'Signature' parameter. Authorization header requires 'SignedHeaders' parameter. Authorization header requires existence of either a 'X-Amz-Date' or a 'Date' header.
Thanks for any help y'all can provide.
Logs
{"message":"Authorization header requires 'Credential' parameter. Authorization header requires 'Signature' parameter. Authorization header requires 'SignedHeaders' parameter. Authorization header requires existence of either a 'X-Amz-Date' or a 'Date' header. Authorization=[my_API_key]"}
Configuration
The headers I am using (straight out of the JAVA code example) are:
`HttpRequest getDevices = HttpRequest.newBuilder()
.uri(new URI("https://api.switch-bot.com/v1.1/devices/{my_lock's_ID}/status"))
.header("Authorization", token)
.header("sign", signature)
.header("nonce", nonce)
.header("t", time)
.GET()
.build();`
Environment
- OS: MacOS 12.5.1
- Software: Java 19.0.1
Additional Context
No response