Amazon API Gateway REST API Reference

integrationresponse:put

Set up an IntegrationResponse for the integration.

HTTP Request

PUT /restapis/<restapi_id>/resources/<resource_id>/methods/<http_method>/integration/responses/{status_code}

Template Variable

Request Body

{
  "selectionPattern" : "String",
  "responseParameters" : {
    "String" : "String"
  },
  "responseTemplates" : {
    "String" : "String"
  },
  "contentHandling" : "String"
}

Request Body Fields

The request accepts the following fields in JSON format.

  • selectionPattern
  • Specifies the selection pattern of a put integration response.

  • responseParameters
  • A key-value map specifying response parameters that are passed to the method response from the back end. The key is a method response header parameter name and the mapped value is an integration response header value, a static value enclosed within a pair of single quotes, or a JSON expression from the integration response body. The mapping key must match the pattern of method.response.header.{name}, where name is a valid and unique header name. The mapped non-static value must match the pattern of integration.response.header.{name} or integration.response.body.{JSON-expression}, where name must be a valid and unique response header name and JSON-expression a valid JSON expression without the $ prefix.

  • responseTemplates
  • Specifies a put integration response's templates.

  • contentHandling
  • Specifies how to handle response payload content type conversions. Supported values are CONVERT_TO_BINARY and CONVERT_TO_TEXT, with the following behaviors:

    • CONVERT_TO_BINARY: Converts a response payload from a Base64-encoded string to the corresponding binary blob.

    • CONVERT_TO_TEXT: Converts a response payload from a binary blob to a Base64-encoded string.

    If this property is not defined, the response payload will be passed through from the integration response to the method response without modification.

Response

IntegrationResponse

Remarks

Example:

Request

The following example PUT request will set up an integration response to pass the 2XX responses from the back end to the client via the corresponding method request.

PUT /restapis/fugvjdxtri/resources/3kzxbg5sa2/methods/GET/integration/responses/200 HTTP/1.1
Content-Type: application/json
Host: apigateway.us-east-1.amazonaws.com
X-Amz-Date: 20160602T233930Z
Authorization: AWS4-HMAC-SHA256 Credential={access_key_ID}/20160602/us-east-1/apigateway/aws4_request, SignedHeaders=content-length;content-type;host;x-amz-date, Signature={sig4_hash}

{
  "selectionPattern" : "2\d{2}",
  "responseParameters" : {
    "method.response.header.Content-Type" : "'application/json'"
  }
}

The input parameters are optional. The selectionPattern parameter corresponds to the HTTP status regex shown in the API Gateway console. If the input parameters are omitted from the input specification ({}), the selectionPattern and responseParameters values remain unspecified, and the responseTemplates will fall back to the pass-through mapping template defaulted to the application/json content type.

Response

The successful (201 Created) response will return the newly created IntegrationResponse resource representation in the payload.

{
  "_links": {
    "curies": {
      "href": "http://docs.aws.amazon.com/apigateway/latest/developerguide/restapi-integration-response-{rel}.html&quot;,
      "name": "integrationresponse",
      "templated": true
    },
    "self": {
      "href": "/restapis/fugvjdxtri/resources/3kzxbg5sa2/methods/GET/integration/responses/200",
      "title": "200"
    },
    "integrationresponse:delete": {
      "href": "/restapis/fugvjdxtri/resources/3kzxbg5sa2/methods/GET/integration/responses/200"
    },
    "integrationresponse:update": {
      "href": "/restapis/fugvjdxtri/resources/3kzxbg5sa2/methods/GET/integration/responses/200"
    }
  },
  "responseParameters": {
    "method.response.header.Content-Type": "'application/json'"
  },
  "selectionPattern": "2\d{2}",
  "statusCode": "200"
}

See Also

AWS CLI