Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

How to create a confluence page from python

Gurram Chandra Kishore
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
March 18, 2022

i need to create a confluence page from python script and should be able to edit from the same python script if needed.

curl -i -X POST \
-H "Authorization:Basic <my-api-token>" \
-H "Content-Type:application/json" \
-H "X-Atlassian-Token:no-check" \
"https://gskr.atlassian.net/wiki/rest/api/content/" \
-d '{
"space" " {"key": "FIR" },
"type": "page",
"title": "Page Created from shell script",
"body": {
"storage": {
"value": "This is my page Content generated from shell script",
"representation": "wiki"
}
}
}'

i used the above shell script but i got authentication error.

1 answer

0 votes
Aron Gombas _Midori_
Community Champion
March 18, 2022

In the authorization header, it is not enough to pass the API token!

In fact, you should:

1. take this string: "yourusername:yourapitoken"

2. base64-encode it

3. pass the resulted string in the "Authorization" header

See this page: https://developer.atlassian.com/cloud/confluence/basic-auth-for-rest-apis/

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events