Uploading attchment using /wiki/rest/api/content/{pageid}/child/attachment results in status 415

Leon André Bergman March 27, 2023

Hi.

I am trying to set up a call to upload files to pages, but I keep hitting a snag where it tells me 415 Unsupported Media Type.

I'm trying to go by what this documentation says:
https://developer.atlassian.com/cloud/confluence/rest/v1/api-group-content---attachments/#api-wiki-rest-api-content-id-child-attachment-put

In Postman I've set up other calls, that work fine. including a GET on /wiki/rest/api/content/{pageid}/child/attachment

For the POST I have set up the header 
X-Atlassian-Token with value nocheck

 

The body is:

{
    file: "{full file path}"
    minorEdit: true
    type: image
}
I have also tested:
{
    file=@"{full file path}"
    minorEdit="true"
    type=image
}
and
{
    file=@"{full file path}"
    minorEdit="true"
    type="image"
}
Does anyone know what the correct working call would be in postman?

1 answer

1 accepted

0 votes
Answer accepted
Oday Rafeh
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
March 27, 2023

Hi @Leon André Bergman

According to the documentation you linked you are missing the Content-Type header in your request, the Content-Type should be set to multipart/form-data for file uploads.

Try adding the following header to your request:

Content-Type: multipart/form-data

Also, make sure that the file path you are using in your request body is correct and that the file exists.

Leon André Bergman March 28, 2023

This was part of the issue.
But I only got it to work after I switched from using Raw , to form-data in the body in Postman.

Added a line with they key st to file.
Under value I browsed for the file I wanted to upload.
I had to show the Content type field under form-data, and set it to multipart/form-data for that file.

Seems this call can send multiple files, and you have to specify content type pr file. Which makes sense once you know its a multi file call, not single file.

Like Oday Rafeh likes this

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
PRODUCT PLAN
PREMIUM
TAGS
AUG Leaders

Atlassian Community Events