Create or update server metadata item¶
Overview¶
Sets a metadata item by key for a specified server.
Classification¶
- Create
API Operation Object¶
- metadata
Synchronous / Asynchronous¶
- -
Request¶
HTTP Request Method¶
- PUT
HTTP Request Path¶
{api_endpoint}/v2/{tenant_id}/servers/{server_id}/metadata/{key}
HTTP Request Header¶
Format¶
Accept-Encoding: gzip, deflate, compress(optional)
Accept: application/json
X-Auth-Token: <token_id>
Content-Type: application/json
Response¶
Sample API Request and Response¶
Sample API Request¶
Request URI¶
https://example.com/v2/{tenant_id}/servers/{server_id}/metadata/{key}
Request Header¶
Accept-Encoding: gzip, deflate, compress (optional)
Accept: application/json
X-Auth-Token: ajk3adjiown02
Request Body¶
- none
Sample API Response¶
Response Header¶
HTTP/1.1 200 OK
<response_code>: see “HTTP Responses” section
<message>: message based on the response code
- skip auto insert field such as “X-Compute-Request-Id” and “Content-Length”, “Date”
Response Body¶
{
"meta": {
"name": "test_server"
}
}
Execution Example¶
HTTP Request¶
PUT /v2/cb8aa2a2c7244af5aab1fa7881ba7f4c/servers/df82dc3f-98e0-4f68-8b75-db8aee7905ab/metadata/key2 HTTP/1.1
User-Agent: curl/7.35.0
Host: 192.168.56.250:8774
X-Auth-Token: 3ca7387517904f04a92d0fd5349890f1
Content-type: application/json
Accept: application/json
Content-Length: 29
HTTP Response¶
HTTP/1.1 200 OK
Content-Type: application/json
Content-Length: 29
X-Compute-Request-Id: req-ab43af96-10e6-4d8a-9b3d-a62d12d5a21c
Date: Thu, 15 Oct 2015 07:04:52 GMT
{"meta": {"key2": "val2_up"}}
Error Execution Example¶
HTTP Request¶
PUT /v2/cb8aa2a2c7244af5aab1fa7881ba7f4c/servers/df82dc3f-98e0-4f68-8b75-db8aee7905ab/metadata/key2 HTTP/1.1
User-Agent: curl/7.35.0
Host: 192.168.56.250:8774
X-Auth-Token: 3ca7387517904f04a92d0fd5349890f1
Content-type: application/json
Accept: application/json
Content-Length: 30
{"metadata": {"key2": "val2"}}
HTTP Response¶
HTTP/1.1 400 Bad Request
Content-Length: 66
Content-Type: application/json; charset=UTF-8
X-Compute-Request-Id: req-57de538d-8316-4eb4-a802-7650f958cea9
Date: Thu, 15 Oct 2015 07:04:59 GMT
{"badRequest": {"message": "Malformed request body", "code": 400}}