Amazon API Gateway REST API Reference

resource:create-child

Creates a child API resource of a given API resource.

HTTP Request

POST /restapis/<restapi_id>/resources/<parent_id>

Request Body

{
  "pathPart" : "String"
}

Request Body Fields

The request accepts the following fields in JSON format.

  • pathPart
  • The last path segment for this resource.

Response

Resource

Remarks

To create a child resource under an existing API resource, make this POST request, specifying the given resource identifier as the in the request URL and the child resource path part in the payload.

Example: Create a child resource under an existing API resource

Request

The following example request creates a child resource under an existing API resource.

POST /restapis/fugvjdxtri/resources/47rxl6 HTTP/1.1
Content-Type: application/json
Host: apigateway.us-east-1.amazonaws.com
X-Amz-Date: 20170223T012846Z
Authorization: AWS4-HMAC-SHA256 Credential={access_key_ID}/20170223/us-east-1/apigateway/aws4_request, SignedHeaders=content-length;content-type;host;x-amz-date, Signature={sig4_hash}

{
    "pathPart" : "res1.1"
}

The pathPart value is defined relative to the specified parent and cannot have the "/" character.

Response

The successful response returns 201 Created status and a payload similar to the following:

{
  "_links": {
    "curies": [
      {
        "href": "http://docs.aws.amazon.com/apigateway/latest/developerguide/restapi-method-{rel}.html&quot;,
        "name": "method",
        "templated": true
      },
      {
        "href": "http://docs.aws.amazon.com/apigateway/latest/developerguide/restapi-resource-{rel}.html&quot;,
        "name": "resource",
        "templated": true
      }
    ],
    "self": {
      "href": "/restapis/fugvjdxtri/resources/m799ha"
    },
    "method:by-http-method": {
      "href": "/restapis/fugvjdxtri/resources/m799ha/methods/{http_method}",
      "templated": true
    },
    "method:put": {
      "href": "/restapis/fugvjdxtri/resources/m799ha/methods/{http_method}",
      "templated": true
    },
    "resource:create-child": {
      "href": "/restapis/fugvjdxtri/resources/m799ha"
    },
    "resource:delete": {
      "href": "/restapis/fugvjdxtri/resources/m799ha"
    },
    "resource:update": {
      "href": "/restapis/fugvjdxtri/resources/m799ha"
    }
  },
  "id": "m799ha",
  "parentId": "47rxl6",
  "path": "/res1/res1.1",
  "pathPart": "res1.1"
}

See Also

Creating an API, AWS CLI