2

I've attempted all solutions (that appear to make sense) from:

And I looked through a handful of other posts that don't apply.

I'm using the Serverless framework to generate my backend. It uses API Gateway with AWS lambda and DynamoDB. In have 4 other API call's that work perfectly, it's only this one call that gives me problems.

Calling code:

//code that calls it
        apiClientFactory = new ApiClientFactory();
        apiClientFactory.credentialsProvider(credentialsProvider);
        accountApiClient = apiClientFactory.build(DevsupercoolsoftwareClient.class);
...
    public static InviteCodeResponseModel createInviteCode(InviteCodeRequestModel request) {
        //request has one value, which is set to "USER"
        InviteCodeResponseModel response = accountApiClient.accountInviteCodeGet(request);
        return response;
    }

Error:

Caused by: com.amazonaws.mobileconnectors.apigateway.ApiClientException: {"message":"The request signature we calculated does not match the signature you provided. Check your AWS Secret Access Key and signing method. Consult the service documentation for details.\n\nThe Canonical String for this request should have been\n'POST\n...\n"}
(Service: DevsupercoolsoftwareClient; Status Code: 403; Error Code: null; Request ID: bd8d4c91-7758-11e6-a0a0-69136ab6b7af)
  at com.amazonaws.mobileconnectors.apigateway.ApiClientHandler.handleResponse(ApiClientHandler.java:255)
  at com.amazonaws.mobileconnectors.apigateway.ApiClientHandler.invoke(ApiClientHandler.java:88)
  at java.lang.reflect.Proxy.invoke(Proxy.java:393)
  at $Proxy1.accountInviteCodeGet(Unknown Source)
  at com.camhart.supercoolsoftware.communicator.BackendCommunicator.createInviteCode(BackendCommunicator.java:62)
  at com.camhart.supercoolsoftware.activities.Devices.triggerShareMenu(Devices.java:159)
  at com.camhart.supercoolsoftware.activities.Devices.access$100(Devices.java:27)
  at com.camhart.supercoolsoftware.activities.Devices$2.doInBackground(Devices.java:134)
  at com.camhart.supercoolsoftware.activities.Devices$2.doInBackground(Devices.java:128)
  at android.os.AsyncTask$2.call(AsyncTask.java:295)
  at java.util.concurrent.FutureTask.run(FutureTask.java:237)
    ... 4 more
Community
  • 1
  • 1
CamHart
  • 3,825
  • 7
  • 33
  • 69

1 Answers1

0

The call to accountInviteCodeGet attempts to do an HTTP GET call with a method body. It appears this isn't allowed. Once I changed it to a POST everything worked great.

I'll try to find some documentation describing this behavior. If I can I'll either edit this or put it in the comments.

Edit: I talked to AWS support. Here's what they pointed me to stating that it's not possible to include message body with HTTP get requests.

"Generally speaking, as per the HTTP/1.1 specification: RFC 2616, section 4.3 clearly states: A message-body MUST NOT be included in a request if the specification of the request method (section 5.1.1) does not allow sending an entity-body in requests. [+] https://www.rfc-editor.org/rfc/rfc2616#section-4.3 "

Community
  • 1
  • 1
CamHart
  • 3,825
  • 7
  • 33
  • 69