SwitchBotAPI icon indicating copy to clipboard operation
SwitchBotAPI copied to clipboard

Authorization Headers work with GET, but not POST

Open becker20 opened this issue 3 years ago • 0 comments

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

becker20 avatar Nov 25 '22 14:11 becker20