Simple confluence REST API usage... What Am I missing?

p j March 18, 2013

I would like to use the Confluence REST API... I am using the Confluence 5.0.2 Evaluation version on my local machine.

From what I understand, the confluence REST API plugin is installed by default. It is present in the list of System add-ons in my admin console.

Being logged in in my web browser all my call to the REST API bring me to the 'Page not found' confluence page

http://localhost:8090/confluence/rest/prototype/1/

http://localhost:8090/confluence/rest/prototype/1/spaces

Are my urls well formed? do I need to configure something more?

thanks!

I also tried the json-rpc api without success....

http://localhost:8090/rpc/json-rpc/confluenceservice-v2

1 answer

1 accepted

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

Post a new question

3 votes
Answer accepted
Jeff Thomas
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
March 18, 2013

The default installation doesn't use the 'confluence' context, try it without:

http://localhost:8090/rest/prototype/1/spaces

Jeff Thomas
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
March 18, 2013

Both versions (with and without context) are mentioned here.

p j March 18, 2013

Great. thanks! is that written somewhere in the documentation?

p j March 18, 2013

ok. thanks!

From what I read here it seems that the api is not yet stable... I'm also giving a look to the JSON-RPC API.... would you recomend going in that direction for an integration project we have with a client currently using confluence?

Jeff Thomas
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
March 18, 2013

You're correct, the REST API is not yet stable and could change at any time. I have not used it personally, but we're using the JSON-RPC API to do some things with our Confluence instance with good results.

p j March 18, 2013

thanks for the reply. one last thing to get me going....

I'm trying the following call to get info on the 'ds' space with the json-rpc light protocol but bet a 'not found' error... var params = JSON.stringify(['ds']);

$.ajax({ url: "http:/localhost:8090/confluence/rpc/json-rpc/confluenceservice-v2/getSpace", type: "POST", data: params, dataType: "json", contentType: "application/json", success: function(space) { console.log(space.name); }, error: function(data) {console.log(data) } });

any idea what I'm doing wrong?

the JSON-RPC plugin seems to be installed by default as well, I do have a space that has the 'ds' key (can see it with the REST interface)....

I have the same error without the confluence context

(i.e. http:/localhost:8090/rpc/json-rpc/confluenceservice-v2/getSpace)

many thanks!

Jeff Thomas
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
March 19, 2013

You're using the confluence context in the URL again, try dropping it.

$.ajax({ url: "http://localhost:8090/rpc/json-rpc/confluenceservice-v2/getSpace", type: "POST", data: params, dataType: "json", contentType: "application/json", success: function(space) { console.log(space.name); }, error: function(data) {console.log(data) } });

Jonny Carter March 19, 2013

Silly, Jeff! He gets the same error without the context. Still, pjdw, make sure you avoid using that.

I'm not too familiar with the JSON-RPC implementation in Confluence, but I'll take a crack at it.

Are you logged in? You can't use token authentication in JSON-RPC, so you'll either have to be logged in to your local confluence instance via the same browser, or use BASIC or OAuth.

What is the exact text of the error you're getting? Is it a URL not found, or is the confluence API returning an error that it couldn't find the space? The JSON-RPC API will return a full JSON-RPC error structure if an error occurs.

p j March 19, 2013

hello guys, sorry for the delay in the reply. got something to work...

var params = JSON.stringify(['ds']); $.ajax({ url: "http://localhost:8090/rpc/json-rpc/confluenceservice-v2/getSpace", type: "POST", data: params, dataType: "json", contentType: "application/json", success: function(space) { console.log('success!!!!'); console.log(space.name); }, error: function(data) {console.log('error:'+data) } });

the route without the context indeed works. second problem was linked to cross-domain restriction limitation in client-side javascript. The code above runs in the javascript console after login in manualy to my confluence server. I will bring this code server side to avoid cross-domain problems...

thanks for your help! will probably come back with some more problem laters... :)

TAGS
AUG Leaders

Atlassian Community Events