What settings i need in api gateway to accept compressed payload

Viewed 540

I have a client application that send compressed data to aws api gateway. The data is defalte compressed. The request headers are as below:
Content-Encoding: deflate
Content-Type: application/json

But i am getting response from aws api : Response code : 415, Response message : Unsupported Media Type and Response body

As per aws documentation AWS API Gateway supports deflate,gzip,identity content encoding. And i am receiving the response from api getway as per this documentation. https://docs.aws.amazon.com/apigateway/latest/developerguide/api-gateway-make-request-with-compressed-payload.html

Below are the settings i made on aws api gateway to accept compressed payload. Please rectify if i am missing any setting or proper combination of settings for this.

1. Request Body on Method Request contains: application/json , application/x-gzip, application/x-gzip-compressed, application/zlib content types.
2. Content Encoding is disabled in settings page. This is to compress the response messgae from api agetway. But in my case i want to send compress message to api gateway. Please rectify if it has something to do with payload compression.
3. Binary Media Types in settings page: I have tried adding application/json, application/zlib and few other content types here. Also tried with wildcard content type as */*.
4. Tested by checking "Use Lambda Proxy integration" in Integration Request. Also tested by unchecking it and using mapping template with option "request body pass through : When there are no templates defined".

Any help is going to be appreciated. :)

1 Answers

Hope you have enabled the payload compression for an API. https://docs.aws.amazon.com/apigateway/latest/developerguide/api-gateway-enable-compression.html

Can you please try to add the following

Accept: application/json
Content-Type: application/json

Note: When API Gateway receives the request, it verifies if the specified content-coding is supported. Then, it attempts to decompress the payload with the specified content coding. If the decompression is successful, it dispatches the request to the integration endpoint. If the specified coding isn't supported or the supplied payload isn't compressed with specified coding, API Gateway returns the 415 Unsupported Media Type error response. The error is not logged to CloudWatch Logs if it occurs in the early phase of decompression before your API and stage are identified.

Related