Forums

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

Unable to create new page under confluence REST API

marafado88 May 14, 2020

I have been following REST API documentation for Confluence, trying to create a new page, but still I have no new page in confluence and json decoder seems to be not working.

This is the command that I am using:

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

This is a confluence version that I use only for test purposes, and I am running curl from the same machine where confluence is hosted in port 8090. The space tag is CM.

With python (who uses python 2) or even python3 (who uses python 3), I am unable to encode curl outputs.

With python 2:

 % Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 35507 0 35507 0 0 236k 0 --:--:-- --:--:-- --:--:-- 237k
No JSON object could be decoded
 

With python 3

 % Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 35507 0 35507 0 0 225k 0 --:--:-- --:--:-- --:--:-- 225k
Expecting value: line 2 column 1 (char 5)

Without using python -json.tool I can see that I can get curl output data, but its hard do understand what may have occur. =/

Anyone knows what I am doing wrong to be unable to create the page in that space and why I am unable to decode in JSON?

1 answer

1 accepted

1 vote
Answer accepted
Hasnae
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
May 14, 2020

I hate to say that "it works on my machine" because that's not really helpful.

So what does the raw output of the curl command look like ? any stack-traces in the logs ? and which version of Confluence are you running ?

marafado88 May 14, 2020

I believe that it works on yours but you know how things work lol.

So, Confluence is at 7.0.1, and the raw output is here:

https://gist.github.com/failover88/6c234ed6e43e99e910ec3ecab06eff2c

Hasnae
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
May 14, 2020

Interesting, it redirects to the dashboard . but I see the following 

```

<meta id="confluence-base-url" name="confluence-base-url" content="http://10.0.0.80:8090">

```

which suggests your instance is deployed at root context `/` instead of `/confluence` , so perhaps you're targeting the wrong endpoint with your command?

try with 

http://localhost:8090/rest/api/content/
Like marafado88 likes this
marafado88 May 14, 2020

Damn, it was that @Hasnae !! Thanks a lot!

Like Hasnae likes this

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events