how to correctly create a page using the API

Jesus Fernandez July 20, 2022

Sorry if I ask something too obvious but I am quite Junior dev and not familiar with curl at all.

I am trying to create a new page following the documentation but I keep getting a 401 response, although if I use the login sample command in the docu (curl -D- -X GET -H "Authorization: Basic <MyEncodedEmailrAndToken>" -H "Content-Type: application/json"https://myspace/wiki/rest/api/space) ) I get a 200 status response, so I assume my login ddetails are correct.

The command I am using is: curl -D- -H "Authorization: Basic  <MYTOKEN>" -X POST -H 'Content-Type:application/json' https://myspace/confluence/rest/api/content/ -d '{"type":"page","title":"TEST", "space":{"key":"AGE2DE"},"body":{"storage":{"value":"Test","representation":"storage"}}}'

And this is the error I keep gettingError.jpg

1 answer

0 votes
Dominic Lagger
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.
July 25, 2022

Hi @Jesus Fernandez 

Does your user have the permission to create a page in this "AGE2DE" space? 

Regards, Dominic

Jesus Fernandez July 25, 2022

HI Dominic, I can create pages manually if that is what you mean, but I cannot create them when using the API command mentioned above

Dominic Lagger
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.
July 25, 2022
Jesus Fernandez July 25, 2022

@Dominic Lagger I am using the example in the documentation so I am not sure what you mean when saying I do not have any headers as I am basically copying the example there and just modify with my space values

Dominic Lagger
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.
July 26, 2022

Hmm this is a bit strange. I just checked with one of my calls.

I have another header: 

'X-Atlassian-Token': 'no-check'

Can you probably check with this? 

If this does not work, I would suggest you to ask in the developer community. 

https://community.developer.atlassian.com/

Regards, Dominic

Suggest an answer

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

Atlassian Community Events