Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

How to get a page from my company confluence using curl?

Jesus Fernandez July 18, 2022

I am trying to learn to use the API (I am a junior developer) I have been going through the documentation and if I do the login as it is mentioned here https://developer.atlassian.com/cloud/confluence/basic-auth-for-rest-apis/ using this command in the windows terminal: curl -D- -X GET -H "Authorization: Basic <MyEncodedEmailrAndToken>" -H "Content-Type: application/json" https://myspace/wiki/rest/api/space I get a 200 response.

But if I try any other method (for instance curl -D- -X GET -H "Authorization: Basic <MyEncodedEmailrAndToken>" -H "Content-Type: application/json" http://localhost:8080/confluence/rest/api/content/3965072?expand=body.storage) from the documenation I always get a 401 error, which is confusing to me as if I am able to use the first command to get the space information why then I get unauthorized response. What am I doing wrong?

1 answer

1 accepted

1 vote
Answer accepted
Craig Castle-Mead
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
July 18, 2022

Hi @Jesus Fernandez 

I'm not sure if the supplied URLs are just examples, or what you're actually using - but in the first (working) example, you're calling https://myspace/wiki/rest, in the second (not working), you reference http://localhost:8080/confluence/rest - just checking that you are using the correct hostname and context/base path for both calls?

When I'm building anything using GET calls on REST endpoints that I can view through a browser - usually by username+password, I'll always check the URL in the browser first, then try and take that known working endpoint and get it working on the command line using my auth token or whatever.

CCM

Jesus Fernandez July 19, 2022

hi @Craig Castle-Mead  yes I am calling in both https://myspace/... it was a typo copy pasting. I am not sure how to view and endpoint through the browser, how would I pass the username and password? and will that work? because when using the console I always got an error saying username and password login is not valid anymore, therefore I had to create a token and use it 

Jesus Fernandez July 19, 2022

Ok I sort it out by using your advice of testing the endpoint on a browser first, it seems I was pointing at the wrong one. Thanks!

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
PRODUCT PLAN
STANDARD
TAGS
AUG Leaders

Atlassian Community Events