Closed Jordan-Eckowitz closed 4 years ago
I changed the endpoint to a GET
request with query string parameters and its working. Just out of interest, is there a way to get this to work for a POST
request?
I've only ever seen examples using GET
but according to the AWS docs it can be done.
Hi @Jordan-Eckowitz,
You can define caching on a POST
method, however the issue seems to be with cache key parameters.
According to AWS Documentation on request data mapping expressions, it should be possible to use method.request.body
or method.request.body.JSONPath_Expression
(this plugin simplifies the declaration and omits the method
prefix).
However, AWS seems to reject CloudFormation templates which use those mappings.
I also can't find a way in the API Gateway console to click through and add body
or a property on the body as a cache key parameter. Maybe I'm missing something though, so please let me know if it's possible through the UI.
In the meantime, I should update the documentation of the plugin and remove request.body
and request.body.JSONPath_EXPRESSION
as possible cache key parameters.
Hi @DianaIonita,
Thanks for the response and creating this plugin - its saved me a lot of time!
There's a section here called Override API Gateway Stage-Level Caching for Method Caching with details on how to setup custom method caching if an endpoint isn't a GET
method. It looks like this would need to be enabled for request body mapping to work.
These are the steps they outline in the docs:
To configure API caching for individual methods using the console:
Sign in to the API Gateway console at https://console.aws.amazon.com/apigateway.
Go to the API Gateway console.
Choose the API.
Choose Stages.
In the Stages list for the API, expand the stage and choose a method in the API.
Choose Override for this method in Settings.
In the Cache Settings area, you can set or clear Enable Method Cache or customize any other desired options. (This section is shown only if stage-level caching is enabled.)
Hi Jordan,
I was looking at that page and I can see options for adding cache key parameters from the query string, header, but nothing about the body:
You've got to go to the endpoint under the Stages
section of the API.
Yes, that's already enabled. The issue is with configuring the cache key parameters under Resources
.
Feel free to reopen this if you have any more information about the issue.
any news on this ? need caching for post body (entire or some specific keys)
I'm trying to enable caching on a
POST
method endpoint based on the request body. When I try and deploy I get the following error (replacing sensitive info with XXXX):Here are my configuration settings for the endpoint (replacing sensitive info with XXXX):
Is there something I'm missing?