Add a Metadata Item

Adds a metadata item for a folder.

Metadata is a collection of name-to-object mappings. Data can be bound to the name for later retrieval. The name (or "key") must be unique and is case-sensitive. The developer is responsible for setting the object value that is associated with this key. The recommended data format is JSON.

Note: For more information about this command, including descriptions of any path and request parameters, request body schema, response codes and schemas, and payload examples, refer to the online API reference for this command at the following web page:

Add a metadata item

URI

https://bartendercloud.com/api/librarian/folders/{folderId}/metadata/{key}

Note: The bartendercloud.com domain that is referenced in the URI and in the code example that follows must be replaced with the contents of the DataCenterURI claim that is extracted from your access token. For more information, refer to Extracting the DataCenterURI Claim.

Path Parameters

folderId

Type: String

Specifies the ID of the folder. Required.

key

Type: String

Specifies the key of the metadata item that you want to add. This parameter must be single-URL encoded. Required.

Query Parameters

None.

Example

Request body: See MetadataCreateItemRequest.

Response: System.Collections.Generic.Dictionary<string, object>

Copy
var client = new HttpClient();
client.DefaultRequestHeaders.Add("Authorization", $"Bearer {accessToken}");

var addRequest = new MetadataCreateItemRequest() {
    Value = "Custom Key Value here"
 };

string keyname = "MyCustomMetadataKey";
HttpRequestMessage request = new HttpRequestMessage
{
    RequestUri = new Uri($"https://bartendercloud.com/api/librarian/folders/{folderId}/metadata/{key}"),
    Content = new StringContent(JsonConvert.SerializeObject(copyRequest), Encoding.UTF8, "application/json"),
    Method = HttpMethod.Post
};

HttpResponseMessage msg = await client.SendAsync(request);

if (msg.IsSuccessStatusCode)
{
    return JsonConvert.DeserializeObject<System.Collections.Generic.Dictionary<string, object>>(await msg.Content.ReadAsStringAsync());
}