I am recieving a 500 "File name cannot be null or empty" error on the CreateAttachment API

I am trying to upload some attachments to a confluence wiki page through the create attachment API.

I am using this javascript rest api as a test but keep getting an error after following all examples I can find on it:

AP.request({
      url: `/rest/api/content/${content_id}/child/attachment`,
      type: "POST",
      contentType: "multipart/form-data",
      data: { file: file, minorEdit: true },
})

image

image

The exact error I get back is: {“statusCode”:500,“message”:“java.lang.IllegalArgumentException: File name cannot be null or empty.”}

Any other fields I might be missing in the request? I don’t see anything else in the documentation on this.

I appreciate your quick response.

Thank You.

Did you manage to resolve this issue?

I am trying to upload images using JavaScript but I get the same error message as you.