Converting build tool that uses xml-rpc to REST API questions

Hi everyone!

I’m sorry if this is a dupe, I tried searching through the documentation, community topics, and google, but I couldn’t find precise or up-to-date answers to my questions.

I’m working on a build tool that currently uses xml-rpc to connect and publish to confluence, allowing the user to experience logging in on the command line and publishing the page they created or updated. We use this tool internally and so do some other companies and nearly everyone using this tool on OSX 10.12 and higher is getting the following error:

Exception caught: (<class 'ssl.SSLError'>)

Exception message: [SSL: SSLV3_ALERT_HANDSHAKE_FAILURE] sslv3 alert handshake failure (_ssl.c:590)

It is very likely that I’m not familiar enough with certificates to understand why we got this in the first place, does anyone know if there is a solution to this?

This error also prompted me to consider using the REST API to post to confluence. I read that admin access is required to use the REST API, is this true? This might not be feasible with the way our security is set up internally, so I’m wondering what the right move is here. I know the xml-rpc api has been deprecated, but will the REST API work with all versions of confluence?

Hi, @dordogh.

In my understanding of the context, you are working with a standalone application (and not a p2 plugin), is this correct? Focusing on your REST API query:

I read that admin access is required to use the REST API, is this true?

It depends on the endpoint you’re referring to; for your use case, I am assuming you’re looking into an endpoint similar to create content, hence, as long as the user you’re going to use for authentication have the necessary permission to create content (with the assumption that you’re using basic auth) then it’s all good.

but will the REST API work with all versions of confluence?

Again, it all depends because “all” is big a scope, but I would say a majority will work. In the event that there are going to be deprecations of public APIs, a sufficient heads-up time will be given. You can also visit our Confluence Server REST API documentation here, if you haven’t already, to have a better appreciation.

Hope this helps, cheers!

Hi @iragudo,

Thank you so much for your reply!

Yes, it is a standalone application and not a plugin; actually, it’s more of a script. I’ve been messing with the API and I’ve managed to make an authorized request to post to the content endpoint and it returns a 200, but the content I receive back is my confluence dashboard and when searching for the page I just tried to post, I can’t seem to find it anywhere.

My curl command was:

curl -u <user>:<password> -X POST -H 'Content-Type: application/json' -d '{"type":"page","title": "test post new api in my dspace","space":{"key":"dspace"},"body":{"storage":{"value":"<p>This is a new page</p>","representation":"storage"}}}' https://confluence.<domain>/confluence/rest/content/

Am I missing something? My account definitely has permission to post to confluence as I can do it with the web GUI, so is it possible that I need to set up OAuth to do a post via the API?

Thank you!

Hi @dordogh,

The URL is /rest/api/content

With regard to if it works with all versions of Confluence? The official REST API at /rest/api was only introduced in Confluence 5.5 and then extended from there - see here
If the lower bound that you want to support is smaller than that, you need to use different APIs (there is still the /rest/prototype/ for some earlier versions).
Cheers, Christoffer

Hi @christoffer,

I also tried the /rest/api/content URL and I had the same result, the URL I posted was one I was messing around with to see if I could get a different result. I’m on Confluence 5.9.5, so I’m not sure why it’s not posting content to the server. Any help here would be really appreciated! Thank you!

Hi, @dordogh.

I also used the same version you did, 5.9.5., then I tried the same curl command you pasted (changing the credentials and baseUrl of course :slight_smile: ) and it worked for me. I was able to successfully create a page via the REST API Browser too. This one’s a bit puzzling; the only difference I can see is that I’m using ‘http’ and not ‘https’, but I cannot hit the same error you have.

Hi @dordogh,

from the information available, I would guess that the reverse-proxy in front of your Confluence is getting in the way: maybe the ULR path is wrong and there is a rewrite rule that sends all traffic not hitting /confluence (or whatever the context-path is) to the dashboard.

Dump more information of curl or use a different client (e.g. Postman) to look at HTTP headers that might reveal any other component taking part in the HTTP connection - otherwise check your nginx / Apache logs.

Good luck

Hi @christoffer and @iragudo,

Thank you for your patience, I was out of town with really limited connection so I couldn’t respond.

It turns out that our internal server doesn’t allow the context in the URL which was causing the issue! I’ve now successfully posted a page using the REST API. Thank you so much for all of your help!!

1 Like

@dordogh You’re welcome