Check Out a File

Checks out a file.

When a user checks a file out from Librarian, that user has exclusive write access to the file. Unless the checkout operation is reverted, only that user can commit a new updated version of the file.

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:

Check out a file

URI

https://bartendercloud.com/api/librarian/files/{fileId}/checkout

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

fileId

Type: String

Specifies the ID of the file to check out. Required.

Query Parameters

None.

Example

Request body: See FileUpdateRequest.

Response: See FileChange.

Copy
// Assume that fileId is the ID of the file to check out. 
var client = new HttpClient();
client.DefaultRequestHeaders.Add("Authorization", $"Bearer {accessToken}");

var fileUpdateRequest = new FileUpdateRequest() {
    Name = "SQL Attachment2",
    Comment = "Rename SQL Attachment to SQL Attachment 2"
};
HttpRequestMessage request = new HttpRequestMessage(new HttpMethod("PATCH"), new Uri($"https://bartendercloud.com/api/librarian/files/{fileId}/checkout"))
{
   Content = new StringContent(JsonConvert.SerializeObject(fileUpdateRequest), Encoding.UTF8, "application/json")
};

HttpResponseMessage msg = await client.SendAsync(request);

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