Create a Tag
Last Updated:2020-10-22
Description
- This API is used to create one or more tags.
- Bind the tag for specific product resources. See Product APIs.
- If the tag to create already exists, skip the creation operation of this tag.
- The tag key and tag value must conform to the specification. For the specific rules, see Tag. The tag key should not be null.
Request
Request structure
PUT /v{version}/tag?create HTTP/1.1
Host: tag.baidubce.com
Authorization: authorization string
{
"tags": [
{
"tagKey": tagKey,
"tagValue": tagValue
}
]
}
Request Header Field
There are no other special header fields except the public header field.
Request Parameters
Parameter Name | Type | Required | Parameter Position | Description |
---|---|---|---|---|
version | String | Yes | URL parameter | API version number |
tags | List<Tag> | Yes | Request Body Parameter | List of tab-key value pair to create |
Return
Return a header field
There are no other special header fields except the public header field.
Return Parameter
No special return parameters are available.
Error Code
Error Code | Error Description | HTTP Status Code | Explanation |
---|---|---|---|
TagExceptions.TagKeyInvalid | Tag key contains invalid characters or length exceeds limit. | 400 | The tag key contains invalid characters or the length exceeds the limit. |
TagExceptions.TagValueInvalid | Tag value contains invalid characters or length exceeds limit. | 400 | The tag value contains invalid characters or the length exceeds the limit. |
TagExceptions.TagKeyEmpty | Tag key should not be empty. | 400 | The tag key should not be null. |
TagExceptions.TagEmpty | Tag should not be empty. | 400 | The tag should not be empty. |
TagExceptions.LimitExceeded | Limit exceeded for current request. | 413 | The total number of tags created exceeds the limit. |
Example
Request Example
PUT /v1/tag?create HTTP/1.1
Host: tag.baidubce.com
Authorization: authorization string
{
"tags": [
{
"tagKey": "key1",
"tagValue": "value1"
},
{
"tagKey": "key2",
"tagValue": "value2"
}
]
}
Return Example
cache-control: no-cache
content-length: 0
content-type: text/plain; charset=utf-8
date: Mon, 09 Apr 2018 09:14:41 GMT
server: BWS
x-bce-request-id: 602b9cda-d803-433b-b902-c6f787ebb7fc