Create a Folder

Creates a new folder.

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:

Create a folder

URI

https://bartendercloud.com/api/librarian/spaces/{spaceId}/folders

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

spaceId

Type: Integer <int32>

Specifies the ID of the requested space. Use the number 1 to target the Main space or the number 2 to target the $temp space. Required.

Query Parameters

None.

Example

Request body: See FolderCreateRequest.

Response: See Folder.

Copy
// Assume spaceId to be the ID of the Space that will contain the new folder
// Assume rootFolderId to be the root folder for the target Space (see GetHierarchy example)
// Create the new folder as a direct child of the Space’s root folder
var client = new HttpClient();
client.DefaultRequestHeaders.Add("Authorization", $"Bearer {accessToken}");

var createRequest = new FolderCreateRequest() {
    Name = “Label Designs”,
    ParentFolderId = rootFolderId,
    isHidden = false,
    InheritPermissionsFromParent = true
};

HttpRequestMessage request = new HttpRequestMessage
{
   RequestUri = new Uri($"https://bartendercloud.com/api/librarian/spaces/{spaceId}/folders"),
   Content = new StringContent(JsonConvert.SerializeObject(createRequest), Encoding.UTF8, "application/json"),
   Method = HttpMethod.Post
};

HttpResponseMessage msg = await client.SendAsync(request);

if (msg.IsSuccessStatusCode)
{
    return JsonConvert.DeserializeObject<Folder>(await msg.Content.ReadAsStringAsync());
}