Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Setting default parameters in method request in api gateway

I have been experimenting with AWS API gateway service. I wanted to give default values to some of the parameters in the method request. However I couldn't find any option to do so. Is there any way to do that from the interface provided ?

like image 465
Vikram Patil Avatar asked Sep 20 '25 12:09

Vikram Patil


2 Answers

You can set a static (i.e. a default/constant) value by using single quotes in the Integration Request mapping.

From the documentation at http://docs.aws.amazon.com/apigateway/latest/developerguide/request-response-data-mappings.html

The STATIC_VALUE is a string literal and must be enclosed within a pair of single quotes.

like image 64
stephan Avatar answered Sep 22 '25 01:09

stephan


I took me a moment to find a good example of this, below are links to more documentation.

  • Method Settings
  • Api gateway swagger
  • Awd labs spec.

Doc Example:

Replace 'parameter-name' with the key and static-value with the value of your static key value pair to add the static param to the request headers.

"responseParameters": {
   "integration.request.header.parameter-name": "'static value'"
}

CDK Example

const lambdaIntegration = new apigateway.LambdaIntegration(lambdaEndpoint, {
   proxy: true,
   requestParameters: {
      "integration.request.header.parameter-name": "'static value'"
   }
});
like image 35
Dejulia489 Avatar answered Sep 22 '25 02:09

Dejulia489