You can call this operation to associate a DHCP options set with a VPC network.

Debugging

OpenAPI Explorer automatically calculates the signature value. For your convenience, we recommend that you call this operation in OpenAPI Explorer. OpenAPI Explorer dynamically generates the sample code of the operation for different SDKs.

Request parameters

Parameter Type Required Example Description
Action String Yes AttachDhcpOptionsSetToVpc

The operation that you want to perform. Set the value to AttachDhcpOptionsSetToVpc.

DhcpOptionsSetId String Yes dopt-o6w0df4epg9zo8isy****

The ID of the DHCP options set.

RegionId String Yes cn-hangzhou

The region where the DHCP options set is deployed. You can call the DescribeRegions operation to query region IDs.

VpcId String Yes vpc-sfdkfdjkdf****

The ID of the VPC network that is to be associated with the DHCP options set.

ClientToken String No 0c593ea1-3bea-11e9-b96b-88e9fe637760

The client token that is used to ensure the idempotence of the request. You can use the client to generate a value that is unique among different requests. ClientToken supports only ASCII characters. It can contain up to 64 ASCII characters.

DryRun Boolean No false

Specifies whether to precheck this request only. Valid values:

true: Runs a precheck without associating the DHCP options set with the VPC network. The system checks whether your AccessKey pair is valid, whether the RAM user is authorized, and whether required parameters are specified. An error message is returned if the request fails the precheck. If the request passes the precheck, the DryRunOperation error code is returned.

false (default value): Runs a precheck and returns a 2XX HTTP status code. After the request passes the precheck, the DHCP options set is associated with the VPC network.

Response parameters

Parameter Type Example Description
RequestId String 0ED8D006-F706-4D23-88ED-E11ED28DCAC0

The ID of the request.

Examples

Sample requests

http(s)://[Endpoint]/? Action=AttachDhcpOptionsSetToVpc
&DhcpOptionsSetId=dopt-o6w0df4epg9zo8isy****
&RegionId=0ED8D006-F706-4D23-88ED-E11ED28DCAC0
&VpcId=vpc-sfdkfdjkdf****
&<Common request parameters>

Sample success responses

XML format

<AttachDhcpOptionsSetToVpcResponse>    
      <RequestId>4DAD3F76-2DB8-4336-B847-D7C0446C7952</RequestId>
</AttachDhcpOptionsSetToVpcResponse>

JSON format

{
  "RequestId": "4DAD3F76-2DB8-4336-B847-D7C0446C7952"
}

Error codes

HTTP status code Error code Error message Description
400 Forbidden.OperateShareResource You cannot operate shared resources. The error message returned because shared resources do not support this operation.
400 InvalidDhcpOptionsSetId.NotFound The specified dhcpOptionsSetId does not exist. The error message returned because the DHCP options set does not exist. Check whether the parameter is correct.
400 IncorrectStatus.DhcpOptionsSet The DhcpOptionsSet status does not support this operation. The error message returned because the DHCP options set that is associated with the VPC network is being configured. As a result, the DHCP options set does not support this operation. You can perform the operation after the DHCP options set becomes available or in use.
400 InvalidVpcId.NotFound Specified value of VpcId is not found in our record. The error message returned because the specified VPC network does not exist. Check whether the specified VPC network ID is valid.
400 IncorrectStatus.VpcDhcpOptionsSet The dhcpOptionsSet status of VPC does not support this operation. The error message returned because the DHCP options set that is associated with the VPC network is being configured. As a result, the DHCP options set does not support this operation.
400 OperationFailed.AttachmentExist The current VPC is already attached to a DHCP options set. The error message returned because the VPC network has been associated with a DHCP options set. You can associate a VPC network with only one DHCP options set.
400 QuotaExceeded.AttachVpcNumber The maximum number of VPCs that can be attached to a DHCP options set is exceeded. The error message returned because the number of VPC networks that can be associated with a DHCP options set exceeds the quota limit.
400 TaskConflict The operation is too frequent. Please wait a moment and try again. The error message returned because the system is busy. Try again later.
404 InvalidRegionId.NotFound The specified RegionId does not exist. The error message returned because the specified region ID does not exist. Check whether the region ID is valid.

For a list of error codes, visit the API Error Center.