I am using https://docs.atlassian.com/ConfluenceServer/rest/6.8.0/ documentation for Creating a Space and writing the content into it. But i am facing authentication issue. If i put GET API in browser and login into confluence then Getting correct Response.
But Same thing is not achieving by sending request from Postman/CURL. It is always returning 403 in response. because the documentation don't have an API for authentication. How i can achieve this?
Kindly have a look at the KB below:
https://developer.atlassian.com/cloud/confluence/basic-auth-for-rest-apis/
It is written there how to provide values for basic authenticaion.
Hi Alex,
Thanks for quick response. I am using my local confluence which is deploy on our local server. how i can generate token for confluence?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
If you execute by curl then it must be like this
curl -D- \ -X GET \ -H "Authorization: Basic dXNlcjp1c2Vy" \ -H "Content-Type: application/json" \ "https://your-domain.atlassian.net/rest/api/2/issue/QA-31"
The Authorization part you do like this:
Authorization
header with content Basic
followed by the encoded string. For example, the string user:userpassword
encodes to dXNlcjp1c2Vy
in base64, so you would make the request as follows:You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Alex,
With reference to this document https://developer.atlassian.com/server/confluence/confluence-rest-api-examples/
curl -u myuser:mypwd -X GET "http://localip/confluence/rest/api/content?type=blogpost&start=0&limit=10&expand=space,history,body.view,metadata.labels"
this is return very basic response below
{"results":[],"start":0,"limit":10,"size":0,"_links":{"self":"http://myip/confluence/rest/api/content?expand=space,history,body.view,metadata.labels&type=blogpost","base":"http://myip/confluence","context":"/confluence"}}
Now same API request i am sending using browser
http://localip/confluence/rest/api/content?type=blogpost&start=0&limit=10&expand=space,history,body.view,metadata.labels
this is returning detailed response of content because i am logged in confluence.
What is the issue in my CURL?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Try not to login to confluence in your browser and execute the rest. Have a look at the returned value.
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.
It means that you are not authorised to Confluence. Try to authorize like in the article, which I provided.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Tried this both
curl -D- \
-u username:pwd \
-X GET \
-H "Content-Type: application/json" \
http://myip/confluence/rest/api/user?username=admin
curl -D- \
-X GET \
-H "Authorization: Basic base64==" \
-H "Content-Type: application/json" \
http://myip/confluence/rest/api/user?username=admin
Getting 403
{"statusCode":403,"data":{"authorized":false,"valid":true,"errors":[],"successful":false,"notSuccessful":true},"message":"User not permitted to view user profiles"}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
http://myip/confluence/rest/api/user?username=admin
Same URL working in browser if i login to confluence
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Make sure that you put user:userpassword correctly to base64.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Yes it is correct . I have encoded my user:password to base64 correctly.Still it is not working for my local confluence.
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.
Hi Alex,
The issue is been fixed. The issue was with my ipaddress . Out local Confluence was running in ip only but api call require port too. Appending port in request URL Fixed my issue.
Thanks,
Ankita
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.