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?
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
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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!
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.