Amazon API Gateway REST API Reference

basepathmapping:create

Creates a new BasePathMapping resource.

HTTP Request

POST /domainnames/<domain_name>/basepathmappings

Request Body

{
  "basePath" : "String",
  "restApiId" : "String",
  "stage" : "String"
}

Request Body Fields

The request accepts the following fields in JSON format.

  • basePath
  • The base path name that callers of the API must provide as part of the URL after the domain name. This value must be unique for all of the mappings across a single API. Leave this blank if you do not want callers to specify a base path name after the domain name.

  • restApiId
  • The string identifier of the associated RestApi.

  • stage
  • The name of the API's stage that you want to use for this mapping. Leave this blank if you do not want callers to explicitly specify the stage name after any base path name.

Response

BasePathMapping

Remarks

To create an empty base path mapping, set the JSON "basePath" property to an empty string, "".

Example: Creates base path mapping for an API

Request

The following example request creates a TestApi base path that is mapped the fugvjdxtri API in the stage1 stage.

POST /domainnames/a.b.c.com/basepathmappings HTTP/1.1
Content-Type: application/json
Host: apigateway.us-east-1.amazonaws.com
X-Amz-Date: 20160615T012033Z
Authorization: AWS4-HMAC-SHA256 Credential={access_key_ID}/20160615/us-east-1/apigateway/aws4_request, SignedHeaders=content-length;content-type;host;x-amz-date, Signature={sig4_hash}

{
  "basePath" : "TestApi",
  "restApiId" : "fugvjdxtri",
  "stage" : "stage1"
}
Response

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

{
  "_links": {
    "curies": {
      "href": "http://docs.aws.amazon.com/apigateway/latest/developerguide/restapi-basepathmapping-{rel}.html&quot;,
      "name": "basepathmapping",
      "templated": true
    },
    "self": {
      "href": "/domainnames/a.b.c.com/basepathmappings/TestApi"
    },
    "basepathmapping:create": {
      "href": "/domainnames/a.b.c.com/basepathmappings"
    },
    "basepathmapping:delete": {
      "href": "/domainnames/a.b.c.com/basepathmappings/TestApi"
    },
    "basepathmapping:update": {
      "href": "/domainnames/a.b.c.com/basepathmappings/TestApi"
    }
  },
  "basePath": "TestApi",
  "restApiId": "fugvjdxtri",
  "stage": "stage1"
}

The API can now be accessed using https://a.b.c.com/TestApi, in addition to the original invocation URL: https://fugvjdxtri.execute-api.us-east-1.amazonaws.com/stage1.

See Also

AWS CLI