HTTP 405 Error when updating an attachment on a page

Hi,

I’m using the v1 REST API to create pages from a program. This is the REST API method I’m trying to use: [PUT] Create or update attachment

I want to update the attachments that already exist on a page.
I’m creating a PUT: {base uri}/rest/api/content/{pageId}/child/attachment but I’m getting a 405 error with no body.

I’ve tried a number of different attempts around the following code but nothing is working for me:

 public async Task UpdateAttachmentAsync(byte[] attachmentContent, string pageId,
     string filename, CancellationToken cancellationToken)
 {
  HttpRequestMessage request = new(HttpMethod.Put, $"content/{pageId}/child/attachment");
  request.Headers.Add("X-Atlassian-Token", "no-check");
  var imageContent = new ByteArrayContent(attachmentContent);
  imageContent.Headers.ContentType = MediaTypeHeaderValue.Parse("image/png");
  imageContent.Headers.ContentLength = attachmentContent.Length;

  var content = new MultipartFormDataContent("BOUNDARY")
  {
      { new StringContent("file"), filename },
      { new StringContent("minorEdit"), "True" },
      { imageContent, "file", filename }
  };
  request.Content = content;

  var response = await _httpClient.SendAsync(request, cancellationToken);

Can you see what I’m doing wrong here?

Thanks,

Dan