Associates a custom route table with a vSwitch in the same virtual private cloud (VPC).
Usage notes
AssociateRouteTable is an asynchronous operation. After a request is sent, the system returns a request ID and runs the task in the background. You can call the DescribeVSwitchAttributes operation to query the status of the task:
- If the vSwitch is in the Pending state, the route table is being associated with the vSwitch.
- If the vSwitch is in the Available state, the route table is associated with the vSwitch.
Debugging
Request parameters
Parameter | Type | Required | Example | Description |
RegionId | String | Yes | cn-hangzhou | The region ID of the VPC to which the route table belongs. You can call the DescribeRegions operation to query the most recent region list. |
RouteTableId | String | Yes | vtb-bp145q7glnuzdvzu2**** | The ID of the route table. |
VSwitchId | String | Yes | vsw-25ncdvfaue4**** | The ID of the vSwitch. |
ClientToken | String | No | 02fb3da4-130e-11e9-8e44-0016e04115b | The client token that is used to ensure the idempotence of the request. You can use the client to generate the token, but you must make sure that the token is unique among different requests. The client token can contain only ASCII characters. Note If you do not specify this parameter, the system automatically uses the request ID as the client token. The request ID may be different for each API request. |
Action | String | Yes | AssociateRouteTable | The operation that you want to perform. Set the value to AssociateRouteTable. |
Response parameters
Parameter | Type | Example | Description |
RequestId | String | DC668356-BCB4-42FD-9BC3-FA2B2E04B634 | The request ID. |
Examples
Sample requests
http(s)://vpc.aliyuncs.com/?Action=AssociateRouteTable
&RegionId=cn-hangzhou
&RouteTableId=vtb-bp145q7glnuzdvzu2****
&VSwitchId=vsw-25naue4****
&<Common request parameters>
Sample success responses
XML
format
HTTP/1.1 200 OK
Content-Type:application/xml
<AssociateRouteTableResponse>
<RequestId>DC668356-BCB4-42FD-9BC3-FA2B2E04B634</RequestId>
</AssociateRouteTableResponse>
JSON
format
HTTP/1.1 200 OK
Content-Type:application/json
{
"RequestId" : "DC668356-BCB4-42FD-9BC3-FA2B2E04B634"
}
Error codes
HttpCode | Error code | Error message | Description |
400 | OperationDenied.CloudBoxVbrEntryExist | The operation is not allowed because the routing table has a route entry for the next hop to the cloud box VBR. | The route table has a route entry that points to the virtual border router (VBR) of the cloud box. |
400 | OperationDenied.OtherCloudBoxVbrEntryExist | The operation is not allowed because the routing table has a route entry for the next hop that points to a VBR other than this cloud box. | The route table has a route entry that points to the VBR of another cloud box. |
400 | OperationDenied.AssociateGatewayRouteTable | The operation is not allowed because gateway route tables cannot be bound to a vSwitch. | The vSwitch cannot be associated with a gateway route table. |
400 | OperationDenied.SwitchToSystemRouteTable | The associated route tables cannot be directly changed to system route tables. | Failed to switch from the associated route table to the system route table. |
404 | InvalidRouteTableId.NotFound | Specified route table does not exist. | The specified route table does not exist. |
404 | IncorrectStatus.RouteTable | The status of the specified route table is incorrect. | The route table is in an invalid state. |
For a list of error codes, see Service error codes.