Update a File Attachment

Updates an existing file attachment.

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:

Update a file attachment

URI

https://bartendercloud.com/api/librarian/attachments/{attachmentId}

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

attachmentId

Type: String

Specifies the ID of the file attachment to update. Required.

Query Parameters

None.

Example

Request body: System.Net.Http.MultipartFormDataContent

Response: See Attachment.
See also: AttachmentUpdateRequest

Copy
// Assume that the stream is of the System.IO.Stream type and references the file content to upload.
// Assume that attachmentId is the ID of the target attachment. 
// Assume that attachmentName is the name that is associated with the attachment that is being updated.
var request = new AttachmentUpdateRequest() {
   Comment = "Update SQL file Sample attachment"
};
var client = new HttpClient();
client.DefaultRequestHeaders.Add("Authorization", $"Bearer {accessToken}");

StreamContent streamContent = new StreamContent(stream);
MultipartFormDataContent multipartFormDataContent = new MultipartFormDataContent
      {
         { new StringContent(JsonConvert.SerializeObject(request)), "attachmentUpdate" },
         { streamContent, "formAttachment", attachmentName }
      };

var msg = await client.PostAsync($"https://bartendercloud.com/api/librarian/attachments/{attachmentId}"
     multipartFormDataContent);

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