I'm having this problem. We have self-hosted confluence at my company. Basic authentication works with curl and username/pw:
curl -D- -u <username>:<password> -X GET -H "Content-Type: application/json" <confluence page to browse>
However, after getting a new API token from confluence website and substituting for the password:
curl -D- -u <username>:<API token> -X GET -H "Content-Type: application/json" <confluence page to browse>
it doesn't work - I get a 401 response and the following message included with other stuff:
Basic Authentication Failure - Reason : AUTHENTICATED_FAILED</p><p><b>Description</b> The request has not been applied to the target resource because it lacks valid authentication credentials for that resource.
It's curious that is used the words Basic Authentication Failure since I'm trying now to use API token and not Basic anymore.
I see answers online about:
- using network name instead of username
- leaving username blank (somehow)
- using email instead of username (for Basic authorization only username works, not email)
But these don't seem to work (and I don't know how to get my network username)
Please can you share the API that you're using?
I tried this API and it works with the <username>:<API token> combination
Documentation : https://developer.atlassian.com/cloud/confluence/rest/v2/api-group-space/#api-spaces-get
Hi Jehan. In fact, I made it work on ubuntu, including remote ubuntu in a docker image. But it doesn't work on Windows. That's where I was stuck.
I am a little confused about which API to use: whether to use Server Confluence REST API or Cloud Conference REST API (and which version). I believe we host our own confluence at Here Technologies where I work. This is the command I used that worked on Ubuntu:
curl -u <Here username:password> -X POST -H 'Content-Type:application/json' -d '{"type":"page","title":"testing_curl_ubuntu","ancestors":[{"id":1949495409}],"space":{"key":"OneMapDev"},"body":{"storage":{"value":"<p>This is a new page</p>","representation":"storage"}}}' https://confluence.in.here.com/rest/api/content/
So, that initial step worked on Linux but the next thing I am stuck on is trying to write the new page with content that includes an image (not as an attachment). It quietly fails and says
Oops - an error has occurred
But it doesn't add the page.
I modified the working initial command to create the blank page, and came up with this:
curl -u username:pw -X POST -H 'Content-Type:application/json' -H 'Accept: application/json' -d '{"type":"page","title":"Sample_Page_With_Images","ancestors":[{"id":1949495409}],"space":{"key":"OneMapDev"},"body":{"storage":{"value":"<p>This is a new page</p><ac:image><ri:attachment ri:filename=\"sino.png\","representation":"storage"}}}' https://confluence.in.here.com/rest/api/content/
So, again I have the parent page underneath which I want to write a new child page. This parent is specified as an ID (1949495409). I basically tweaked my previous command to simply add the image (sino.png). But the ri:attachment seems to indicate it is trying to attach something. I only want to write the image directly into the doc as a rendered image.
I based this code on a different form of the command I found in:
https://community.atlassian.com/t5/Confluence-questions/is-it-possible-to-upload-a-image-in-confluence/qaq-p/1254693
thanks
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
The command was slightly wrong (no closing </ac:image>) but it didn't help:
curl -u username:pw -X POST -H 'Content-Type:application/json' -H 'Accept: application/json' -d '{"type":"page","title":"Sample_Page_With_Images","ancestors":[{"id":1949495409}],"space":{"key":"OneMapDev"},"body":{"storage":{"value":"<p>This is a new page</p><ac:image><ri:attachment ri:filename=\"sino.png\" /></ac:image>,"representation":"storage"}}}' https://confluence.in.here.com/rest/api/content/
Some error details are given below:
Exception ID: 7f2f8d55-4656-4d1c-91e5-5fc0329799e0
Unknown
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.