Hi!
I am trying to test out the REST API provided by confluence. We are running confluence version 5.5.6. (which is supposed to provide a REST API)
When I try to create a new page using curl, as described in this example https://developer.atlassian.com/confdev/confluence-server-rest-api/confluence-rest-api-examples
(see the "Create a new page" header) I get an http 200 code, along with the the front page of our confluence site returned in html, and no new page is created in confluence
When I try to "Find a page by title and space key"
I also get a standard confluence html page with containing the errormessage. "The page you were trying to reach could not be found." (even though I'm pretty sure the title and space key is accurate), along with the 404 message
According to the documentation https://developer.atlassian.com/confdev/confluence-server-rest-api/confluence-rest-api-examples
I expected the response to be json structured (even when error codes are returned)
Remote API's are enable in the config, althought it only specifies XML-RPC & SOAP, not REST.
Any ideas to what I am doing wrong? to have html returned rather than JSON.
And why does my requests fail(is it related to the response format problem) ?
Thanks
Tor
I had this same issue, but solved it. Here are what I went through, which may help someone.
First I wondered if I was getting an http status code returned, along with the html. So I performed a 'curl -I' to only show me the head. I've truncated the response below:
name@host:~/atlassian$ curl -I http://localhost:8090/confluence/rest/api/content
HTTP/1.1 404
404? File not found.
So, as a guess, I removed the the first part of the URL, and now I get json returned, as desired.
name@host:~/atlassian$ curl -u admin:admin -X GET "http://localhost:8090/rest/api/content?type=blogpost&start=0&limit=10&expand=space,history,body.view,metadata.labels" | python -mjson.tool
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 208 0 208 0 0 5621 0 --:--:-- --:--:-- --:--:-- 5621
{
"_links": {
"base": "http://localhost:8090",
"context": "",
"self": "http://localhost:8090/rest/api/content?expand=space,history,body.view,metadata.labels&type=blogpost"
},
"limit": 10,
"results": [],
"size": 0,
"start": 0
}
This worked for me. I think the documentation (with /confluence) refers to confluence cloud and without "/confluence" in URL is to be used with confluence server.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Legend!!! Thank You!!!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
This is happening fo me as well.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
same here
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi!
This issue is still unresolved
The current situation is that when I issue the curl statement
curl -v -u admin:admin -X POST -H 'Content-Type: application/json' -d'{"type":"page","title":"Another new page 2","space":{"key":"DEMO"},"body":{"storage":{"value":"<p>This is a new page created by a REST call</p>","representation":"storage"}}}' -L https://confluence/confluence/rest/api/content/
I get a 302 message along with the following log message
"Issue another request to this URL: 'http://confluence.vps.no/confluence/rest/api/content/'
* Switch from POST to GET"
This is followed by the execution of the get , and the following log message is displayed
"Connection #1 to host confluence.vps.no left intact
* Issue another request to this URL: 'http://confluence/dashboard.action;jsessionid=933054514D00EB6A58978192640A2D29' "
HTTP 200 is returned by the GET along with an HTML body containing our confluence front page(more or less)
And No new confluence page has been created
I have also tried to execute the same curl (POST) statement although replacing the url with http://confluence/dashboard.action;jsessionid=933054514D00EB6A58978192640A2D29'
And HTTP 200 is returned by the POST along with the confluence front page as an HTML body.
And no new page has been created
I know that we are redirecting http requests to confluence to https, but nothing else(to my knowledge).
Or could there be an redirection issue with the behaviour I am experiencing?
Any other ideas?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Tor,
The request being sent was malformed, try it with the following:
curl -v -u admin:admin -X POST -H 'Content-Type: application/json' -d'{"type":"page","title":"Another new page 2","space":{"key":"DEMO"},"body":{"storage":{"value":"<p>This is a new page created by a REST call</p>","representation":"storage"}}}' -L http://confluence/confluence/rest/api/content/
You'll notice if you compare your request to mine, I added a "} to close out the space key tuple. I tested this against my test Confluence installation and it worked (I also noticed you don't have a port following the hostname, so I assume you are either running Confluence directly on port 80 or have some kind of redirection from 80 to the port Confluence is using).
You should receive the following response:
{"id":"622593","type":"page","title":"Another new page 2","space":{"id":491521,"key":"DEMO","name":"Test","type":"global","_links":{"self":"http://branno.local:5556/conf/rest/api/space/DEMO"},"_expandable":{"icon":"","description":"","homepage":"/rest/api/content/360452"}},"history":{"latest":true,"createdBy":{"type":"known","profilePicture":{"path":"/conf/s/en_GB/5527/d6c318572c182872608bdc1754f542eab16839cb.1/_/images/icons/profilepics/default.png","width":48,"height":48,"isDefault":true},"username":"admin","displayName":"admin"},"createdDate":"2016-12-16T15:10:15.792-0600","_links":{"self":"http://branno.local:5556/conf/rest/api/content/622593/history"},"_expandable":{"lastUpdated":""}},"version":{"by":{"type":"known","profilePicture":{"path":"/conf/s/en_GB/5527/d6c318572c182872608bdc1754f542eab16839cb.1/_/images/icons/profilepics/default.png","width":48,"height":48,"isDefault":true},"username":"admin","displayName":"admin"},"when":"2016-12-16T15:10:15.792-0600","message":"","number":1,"minorEdit":false},"ancestors":[],"container":{"id":491521,"key":"DEMO","name":"Demo","type":"global","_links":{"self":"http://branno.local:5556/conf/rest/api/space/DEMO"},"_expandable":{"icon":"","description":"","homepage":"/rest/api/content/360452"}},"body":{"storage":{"value":"<p>This is a new page created by a REST call</p>","representation":"storage","_expandable":{"content":"/rest/api/content/622593"}},"_expandable":{"editor":"","export_view":"","view":""}},"_links":{"webui":"/display/DEMO/Another+new+page+2","tinyui":"/x/AYAJ","collection":"/rest/api/content","base":"http://branno.local:5556/conf","self":"http://branno.local:5556/conf/rest/api/content/622593"},"_expandable":{"children":"/rest/api/content/622593/child","descendants":"/rest/api/content/622593/descendant","metadata":""}}
Stephen
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Stephen,
As you say my request was malformed, a "}" was missing. However using your version of the request, only substituting username/password and server fared no better. The response is still html, and as far as I can see the response is identical to the one I got when the "}" was missing.
Regarding the missing port, we are redirecting the standard url (to an https version)
Tor
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi!
The curl statement I've been using is :
curl -v -u admin:admin -X POST -H 'Content-Type: application/json' -d'{"type":"page","title":"Another new page 2","space":{"key":"DEMO,"body":{"storage":{"value":"<p>This is a new page created by a REST call</p>","representation":"storage"}}}' -L http://confluence/confluence/rest/api/content/
(I just modified username/password and the servername of our confluence instance)
I have added the -L option to follow redirects as I otherwise get no response.
Tor
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Tor,
I installed a brand new instance of Confluence 5.5.6 and used the REST API example to create a new page. This worked as expected. I then used the example to find a page by name and space (to find the created page) and that also worked as expected.
I'd really like to see the exact REST call being made, as it could explain why we aren't getting the results we expect.
Stephen Brannen
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Well. I tried using an invalid username/password combination when attempting to post a new page.
It resulted in an explicit http 401 error message , along with a html message body.
So it does not seem to be an issue with using the username and password which is supposed to work (which I can log into confluence with using a browser)....
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Ok, I'm not sure.
I get the login page when I'm trying to log in with auth data that has expired, but it's fine when I hit a valid page with the plain text user/password ("curl -D- -u admin:admin ..." type command). I assume that's what you're doing, and I don't know why it might be returning a login page.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
It often means you have not logged in, or it's not recognised the user credentials you've given it.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.