Post html files on Page In Confluence Via Rest API using Java

1.4k Views Asked by At

Does anyone has any example on how to attach html files on Page in Confluence using Confluence's RESTful API? I'm trying to write something in Java that can do this.

The api exposed by the atlassian is POST /wiki/rest/api/content/{id}/child/attachment but what is {id} here

Suppose my confluence page is https://wiki.company.com/Results/DemoResults/Reports

I made foll request from postman:

POST https://wiki.company.com/rest/api/content/{id}/child/attachment

In params I gave multipart/form-data:object

In authorization I gave my creds and has chosen basic auth as type

In header I gave X-Atlassian-Token: nocheck

I am getting below errors:

  1. { "statusCode": 500, "message": "", "reason": "Internal Server Error" }

  2. Unable to verify the first certificate

1

There are 1 best solutions below

3
On

You can't POST arbitrary HTML into a Confluence page because Confluence is not storing its pages in HTML but their own storage format.

If you instead mean to upload the HTML file as an attachment you should use the attachment REST API.

You can use this endpoint :

POST /rest/content/{id}/child/attachment, here id path variable is the page id

See documentation :

https://docs.atlassian.com/atlassian-confluence/REST/6.5.2/