question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

when I updated `aws-api-gateway-client` from 0.2.17 to version 0.3.3 my Requests failed with status code 403 however it was working well before updating

See original GitHub issue
export function apiRequest(options, cred, result, error) {
  var apigClientFactory = require("aws-api-gateway-client").default;
  var apigClient = apigClientFactory.newClient({
    invokeUrl: BASE_URL, // REQUIRED
    region: "us-east-1", // REQUIRED: The region where the API is deployed.
    accessKey: cred.accessKeyId, // REQUIRED
    secretKey: cred.secretAccessKey, // REQUIRED
    sessionToken: cred.sessionToken, // OPTIONAL: If you are using temporary credentials
    systemClockOffset: 0, // OPTIONAL: An offset value in milliseconds to apply to signing time
    retries: 2, //           function. Uses axios-retry plugin. Default is no delay.
    retryDelay: "exponential"
  });
  var pathParams = {};
  // Template syntax follows url-template https://www.npmjs.com/package/url-template
  var method = "POST";
  var additionalParams = {
    //If there are query parameters or headers that need to be sent with the request you can add them here
    headers: {
      "Content-Type": "application/json"
    },
    queryParams: {}
  };
  console.log("api client", apigClient);
  apigClient
    .invokeApi(
      pathParams,
      `/default/${options.pathTemplate}`,
      method,
      additionalParams,
      options.body
    )
    .then(response => {
      //This is where you would put a success callback
      console.log(`${options.pathTemplate} invoke api result`, response);
      result(response);
    })
    .catch(err => {
      //This is where you would put an error callback
      console.log(`${options.pathTemplate} invoke api error`, err);
      error(err);
    });
}

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:9 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
guizy67commented, May 28, 2020

Hi,

I have the same issue after updating to version 0.3.3. Initially I reverted to 0.2.17, where the identical code worked again.

After reading @AhmedMesawer post, I tested again with v 0.3.3. First without changing any code, same issue. Symptom is a Content-Length: 0 in the request.

After commenting out the retries everything works as expected.

var apigClient = apigClientFactory.newClient({
    invokeUrl: config.api.invokeUrl,
    ...
    region: config.api.region,
    systemClockOffset: 0, // OPTIONAL
    //retries: 4,         // OPTIONAL
    retryCondition: (err) => { // 
        return err.response && err.response.status === 500;
    }
});

Looks like this is the source of the bug.

1reaction
mpashkovskiycommented, Mar 11, 2020

@AhmedMesawer I run into the same problem with 0.3.3. Switching headers to lower case helped me. Try “content-type”.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Fix 403 Forbidden errors when connecting to API Gateway ...
Last updated: 2022-06-17. I'm calling my Amazon API Gateway APIs from my virtual private cloud (VPC), but I get an HTTP 403 Forbidden...
Read more >
How do I troubleshoot HTTP 403 errors from API Gateway?
... Knowledge Center article with this video: https://aws.amazon.com/premiumsupport/knowledge-center/api-gateway-troubleshoot- 403 -forbid...
Read more >
API.get Sometimes gets 403. · Issue #3567 · aws-amplify ...
Describe the bug Suddenly the response of API.get gets 403. (signature doesn't match) After once I got 403, I keep getting 403 ever....
Read more >
AWS Lambda function REST API end point - 403 error
One reason why you'd get 403 on a fresh "no authentication" API Gateway resource is because you haven't yet deployed your changes.
Read more >
403 Forbidden Error when calling an AWS API Gateway in ...
I set up a REST API in AWS with a PUT method to upload files to an S3 bucket. The "Authorization" field in...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found