Forums

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

Getting 401 error

Dastagiri February 26, 2022

Hi everyone,

I am trying to get confluence page response using rest API in below format, but getting like 401 unauthorised. I can access in gui without any issues. I can see in  few posts like basic authentication is deprecated. I don't have option to generate oauth. Is there any way that I can overcome this issue?

Curl -k -x get https:// url -u id: password

2 answers

1 accepted

0 votes
Answer accepted
Pramodh M
Community Champion
February 26, 2022

@Dastagiri 

curl -k  -u 'username:password's -X GET https://url

Does your password have special characters?

Encode with HTML parameters

https://www.w3schools.com/tags/ref_urlencode.asp

If your instance is not secured with HTTPS go with http://url

Ensure username is not Email ID and it is username you use for login  and password is the one you use for login

 Can you attach the screenshots of the error you are getting?

Let me know

Thanks

Dastagiri February 26, 2022

Hi pramod,

Thank you so much for your response. I am using using https and my password have special characters in my password. So I replaced like "user":"password" then it's working. Now another issue when updating page using put its showing  status code 500 internal server error.  Below is the code i am using.
response=$(curl -X GET url\
-H 'Content-Type:"application/json' -k \
-u "${username}":"${password}")

version_temp=${response##*'number":'}
version=${version_temp%%%%','*}
version=$((version+1)) #increment version
response=$(curl -X PUT ${confluenceurl} \
-H 'Content-type: application/json' -k \
-u "${confluence_user}":"${confluence_password}" \
-d '{
"id": page id,
"type": "page",
"title": "page title",

"space": {"key": "Myspace"},

"body": {
"storage": {
"value": ","${content}",",
"representation": "storage"
}
}')

Please let me know if I am making some mistake.

Thanks,

Dastagiriawk -F',' 'BEGIN{ print "<table border=1>"; print "<tr><th>Name</th><th>Bounce</th><th>Department</th></tr>"} { print "<tr><td>" $1 "</td><td>" $2 "</td><td>" $3 "</td></tr>" } END{ print "</table>"}' input.csv 

Dastagiri February 26, 2022

you can find content= $(awk -F etc at the end of message, as it is not allowing to post html content. Is there anyway that I can make changes to code if it is wrong format?

0 votes
Pramodh M
Community Champion
February 26, 2022

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events