aws-api-gateway

AWS API Gateway ERR_CONTENT_DECODING_FAILED in browser

旧巷老猫 提交于 2019-11-29 18:09:26
In my use case, API Gateway serves as an HTTP proxy, using default settings following official tutorial . It's tested working in test console or via curl. But if I access the link in browser or make an AJAX call, I'll get ERR_CONTENT_DECODING_FAILED . It seems that API Gateway corrupt the content. Related issue . Is there a way to forbid API Gateway changing my content? I set Content Handling to passthrough , but clearly it's changing my content. Add a static integration request header Accept-Encoding with value 'identity' , so that AWS won't tamper your request. 来源: https://stackoverflow.com

AWS API Gateway Header and Body Mappings in Integration Response

我的梦境 提交于 2019-11-29 17:54:18
I am trying to properly setup Body Mapping and Header Mapping in the Integration Response for an API Gateway endpoint. In our Lambda we have if (response.statusCode == 200) { context.succeed(output); } else if (response.statusCode == 206) { var paginationObject = { errorType : "PartialContent", errorCode : 206, detailedMessage : "PartialContent Returned", stackTrace : [], data : { output } }; context.fail(JSON.stringify(paginationObject)); } I then handle fetching this in the Integration Response using a Lambda Error Regex of .*PartialContent.* and have my Body Mapping Template as #set(

How to pass array query params to AWS API Gateway?

回眸只為那壹抹淺笑 提交于 2019-11-29 17:46:58
问题 A Rails API typically likes array query params like this: example.com?colors[]=cyan&colors[]=magenta&colors[]=yellow&colors[]=black How would I map that through to a lambda function? 回答1: A little trial and error shows that it's like this: example.com?colors=['cyan','magenta','yellow','black'] 回答2: One thing you can't do is have duplicated query string param keys as per https://docs.aws.amazon.com/apigateway/latest/developerguide/api-gateway-known-issues.html: Duplicated headers are not

AWS API Gateway endpoint gives CORS error when POST from static site on S3

只谈情不闲聊 提交于 2019-11-29 16:56:34
问题 I have created an API endpoint with Serverless(serverless.com) which I expose through API Gateway. I'm getting following error though I have enabled CORS from the XMLHttpRequest cannot load https://xxxxxxxxx.execute-api.us-west-2.amazonaws.com/development/signup. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://yyyyyyyyy.com.s3-website-us-east-1.amazonaws.com' is therefore not allowed access. I don't get any errors when I use Postman to make

API Gateway CORS Issue

China☆狼群 提交于 2019-11-29 15:18:15
问题 So I have CORS enabled going through the basic setup given by AWS Gateway. However for this API I need to allow Control Origins for all requests and allow credentials. Here is what it looks like The issue as you may have guessed is this setup is not allowed by CORS, you can not have a wildcard for Origin and have credentials as true. Normally the work around for this is to just grab the requesting domain and add it into the Origin Header. Which is more or less what I want to do. But I don't

Using AWS Gateway API, can I access the cookies?

蹲街弑〆低调 提交于 2019-11-29 14:09:26
问题 Using a HTTP Proxy Integration I want to access the cookies and add one to the json response. Is that possible? 回答1: To access cookies sent by the client in your backend you'll have to setup a mapping from the method request header to your integration request header. These instructions assume you've already setup a simple method in API Gateway. Access cookies in your backend Under Method Request, create an HTTP Request Header with the name of "Cookie" Under Integration Request, create an HTTP

How to access http headers in custom authorizer AWS lambda function

和自甴很熟 提交于 2019-11-29 13:33:26
问题 From API Gateway, I created a custom authorizer for my API using Lambda function in python. API Gateway hands over the incoming auth token using a header I configure( method.request.header.Authorization ). However I also need the other headers of the original http request inside my lambda function. How do I access them? I did not see the headers on event object input to my lambda function. Note that this is not a duplicate of How to access HTTP headers for request to AWS API Gateway using

How can I grant permission to API Gateway to invoke lambda functions through CloudFormation?

倾然丶 夕夏残阳落幕 提交于 2019-11-29 12:30:36
问题 I've been all over the web searching for an answer to this. Essentially, we're spinning up an API using Swagger, which is awesome and works great, but one thing doesn't work... When we make a call to an Endpoint, we get a 500 error (it's not a 500 error that we're providing either it's one from AWS). The error states "Execution failed due to configuration error: Invalid permissions on Lambda function" (https://youtu.be/H4LM_jw5zzs <- This is a video, from another user, of the error I'm

How to call API Gateway with Cognito Credentials through retrofit2 on Android?

元气小坏坏 提交于 2019-11-29 09:41:10
问题 I use retrofit2 in my android apps for any http/rest call. Now I need to call an api generated with Amazon AWS API Gateway. The AWS documentation say I should generate the client code throw the API Gateway console and use the class ApiClientFactory to build the request: ApiClientFactory factory = new ApiClientFactory(); // Use CognitoCachingCredentialsProvider to provide AWS credentials // for the ApiClientFactory AWSCredentialsProvider credentialsProvider = new

How to upload file to lambda function or API Gateway?

删除回忆录丶 提交于 2019-11-29 03:47:33
I'm try to upload file from iOS to AWS API Gateway and passthrough it to Lambda function, How can I implement this scenario? I can use multipart/form-data to upload to AWS API Gateway but how make input Model support binary data? [Edit1] moved from answer by Spektre Thanks For response, after a little of reading I figure out that's no way to upload file to lambda (and it's not logical because it's event based) and the only valid use case to upload to S3 and make S3 notify lambda. kixorz I'd highly recommend using direct S3 upload using one of the AWS SDKs . AWS Lambda is suited to process just