Skip to content
v2.278.0

MethodResponse Struct ​

Example ​

ts
// The code below shows an example of how to instantiate this type.
// The values are placeholders you should change.
import { aws_apigateway as apigateway } from 'aws-cdk-lib';

declare const model: apigateway.Model;
const methodResponse: apigateway.MethodResponse = {
  statusCode: 'statusCode',

  // the properties below are optional
  responseModels: {
    responseModelsKey: model,
  },
  responseParameters: {
    responseParametersKey: false,
  },
};
python
# The code below shows an example of how to instantiate this type.
# The values are placeholders you should change.
from aws_cdk import aws_apigateway as apigateway

# model: apigateway.Model

method_response = apigateway.MethodResponse(
    status_code="statusCode",

    # the properties below are optional
    response_models={
        "response_models_key": model
    },
    response_parameters={
        "response_parameters_key": False
    }
)
java
// The code below shows an example of how to instantiate this type.
// The values are placeholders you should change.
import software.amazon.awscdk.services.apigateway.*;

Model model;

MethodResponse methodResponse = MethodResponse.builder()
        .statusCode("statusCode")

        // the properties below are optional
        .responseModels(Map.of(
                "responseModelsKey", model))
        .responseParameters(Map.of(
                "responseParametersKey", false))
        .build();
csharp
// Install: dotnet add package Amazon.CDK.Lib
// The code below shows an example of how to instantiate this type.
// The values are placeholders you should change.
using Amazon.CDK.AWS.APIGateway;

Model model;

var methodResponse = new MethodResponse {
    StatusCode = "statusCode",

    // the properties below are optional
    ResponseModels = new Dictionary<string, IModel> {
        { "responseModelsKey", model }
    },
    ResponseParameters = new Dictionary<string, boolean> {
        { "responseParametersKey", false }
    }
};
go
// Install: go get github.com/aws/aws-cdk-go/awscdk/v2
// The code below shows an example of how to instantiate this type.
// The values are placeholders you should change.
import "github.com/aws/aws-cdk-go/awscdk"

var model Model

methodResponse := &MethodResponse{
	StatusCode: jsii.String("statusCode"),

	// the properties below are optional
	ResponseModels: map[string]IModel{
		"responseModelsKey": model,
	},
	ResponseParameters: map[string]*bool{
		"responseParametersKey": jsii.Boolean(false),
	},
}

Properties ​

responseModelsoptional{ [key: string]: IModel }response_modelsoptionaltyping.Mapping[str, IModel]responseModelsoptionalMap<String, IModel>ResponseModelsoptionalIDictionary<string, IModel>ResponseModelsoptional*map[string]IModel = None #
The resources used for the response's content type.

Specify response models as key-value pairs (string-to-string maps), with a content type as the key and a Model resource name as the value.

responseParametersoptional{ [key: string]: boolean }response_parametersoptionaltyping.Mapping[str, bool]responseParametersoptionalMap<String, Boolean>ResponseParametersoptionalIDictionary<string, bool>ResponseParametersoptional*map[string]*bool = None #
Response parameters that API Gateway sends to the client that called a method.
notes

Specify response parameters as key-value pairs (string-to-Boolean maps), with a destination as the key and a Boolean as the value. Specify the destination using the following pattern: method.response.header.name, where the name is a valid, unique header name. The Boolean specifies whether a parameter is required.

statusCodestringstatus_codestrstatusCodeStringStatusCodestringStatusCode*string required #
The method response's status code, which you map to an IntegrationResponse.

Required.