How to create a new page in Confluence using REST API?

I need a working example of creating a new merge wiki page using rest api. I prefer that a new page be created under a specific space and specific page. I read their api documentation and looked at a few examples that they had and is still close.

Here is an example they had on their site

curl -u admin:admin -X POST -H 'Content-Type: application/json' -d'{"type":"page","title":"new page","space":{"key":"TST"},"body":{"storage":{"value":"<p>This is a new page</p>","representation":"storage"}}}' http://localhost:8080/confluence/rest/api/content/ | python -mjson.tool

I tried above with my space name, new header and changed the url to mysite / rest / api / content and the returned content was basically an html page saying that the page does not exist or the page exists but you do not have permission . I confirmed that I have access to the wiki wiki and I can create a new wiki using my credentials.

What is also unclear in the above example, how does it call the specific api that creates the page? This makes no sense.

A similar question was asked on their forum, but no reasonable answer https://answers.atlassian.com/questions/149561/simple-confluence-rest-api-usage-what-am-i-missing

(I assume my ultimate goal is to create a new merge wiki page automatically). I am fine, if necessary, to abandon the REST API to merge with another solution.

+24
source share
2 answers

, Confluence. API REST Confluence 5.5 ( 8 ). API , , Confluence. 5.5 API API- , , . URL-, API, Confluence.

Confluence 5.4 REST API (/rest/ prototype/1/content), .

Atlassian , "/" URL-, , Confluence . , Confluence 5.5+ ( , ).

, Confluence, os_authType.

Confluence 5.5 ( ).

Accept, .

curl -v -u admin:admin -X POST -H 'Content-Type: application/json' -H 'Accept: application/json' -d'{"type":"page","title":"new page","space":{"key":"ATTACH"},"body":{"storage":{"value":"<p>This is a new page</p>","representation":"storage"}}}' "http://localhost:8090/rest/api/content/?os_authType=basic"

, API, , URL- . , GET "/rest/api/content" ( ), POST .

:

. , , .

+27

REST api, , . :

curl -X GET \
'<your-confluence-URL>/pages/movepage.action?pageId=<page-to-be-moved-pageId>&spaceKey=<target-space-key>&targetTitle=<target-title-of-parent-page>&position=append' \
-H 'authorization: Basic <encoded-username-password>' \ 
-H 'x-atlassian-token: no-check'

curl -X GET \
'<your-confluence-base-URL>/pages/movepage.action?pageId=<page-to-be-moved-pageId>&spaceKey=<target-space-key>&position=topLevel' \...
0

Source: https://habr.com/ru/post/1546653/


All Articles