Basic Authentication Failure - Reason : AUTHENTICATION_DENIED
Asked by rahul rajeev:

I am using Confluence data center to generate users invitation link using bash script  

CONFLUENCE_URL="<http://localhost:XXXX>"  
ENDPOINT= rest/invitation/1.0/invitation-link  
USERNAME="admin"  
API_TOKEN="XXXX"  
# Make POST request to create a new invitation link  
INVITE_RESPONSE=$(curl -s -u "${USERNAME}:${API_TOKEN}" -X POST \\  
-H "Content-Type: application/json" \\  
-H "Accept: application/json" \\y  
-d '{"expirationDate": "2025-02-26T00:00:00.000Z"}' \\  
"${CONFLUENCE_URL}/${ENDPOINT")  
But getting authentication error

\<!doctype html\>\<html lang=en\>\<head\>\<title\>HTTP Status 401 -- Unauthorized\</title\>\<style type=text/css\>body {font-family:Tahoma,Arial,sans-serif;} h1, h2, h3, b {color:white;background-color:#525D76;} h1 {font-size:22px;} h2 {font-size:16px;} h3 {font-size:14px;} p {font-size:12px;} a {color:black;} .line {height:1px;background-color:#525D76;border:none;}\</style\>\</head\>\<body\>\<h1\>HTTP Status 401 -- Unauthorized\</h1\>\<hr class=line /\>\<p\>\<b\>Type\</b\> Status Report\</p\>\<p\>\<b\>Message\</b\> Basic Authentication Failure - Reason : AUTHENTICATION_DENIED\</p\>\<p\>\<b\>Description\</b\> The request has not been applied because it lacks valid authentication credentials for the target resource.\</p\>\<hr class=line /\>\<h3\>Apache Tomcat/9.0.54\</h3\>\</body\>\</html\>


Answers:
author: Marc - Devoteam
body: Hi [@rahul rajeev](/t5/user/viewprofilepage/user-id/5433114)

There is no invitation endpoint in the API.

You can create a user via the API and have them receive a notification.

See api related topic here: [user-createUser](https://docs.atlassian.com/ConfluenceServer/rest/8.8.0/#api/admin/user-createUser)

comments: author: Marc - Devoteam
body: The only API that had this option was bitbucket.

<https://support.atlassian.com/bitbucket-cloud/docs/invitations-resource/>

But only in API version 1, and that removed since 2019


author: rahul rajeev
body: Hi [@Marc - Devoteam](/t5/user/viewprofilepage/user-id/3796976)   

Thank You for your response.  

Is there a way to regenerate user invitation link in confluence data center(8.5.5) automatically using bash script?


author: Marc - Devoteam
body: Hi [@rahul rajeev](/t5/user/viewprofilepage/user-id/5433114)

No there is none.

The only option is as I mentioned before, create the new users via the API and have the sent notification on "true".


author: Humashankar VJ
body: Hi - I hope that you are Doing good !!

Looks authentication credentials provided in your Bash script are not being accepted by Confluence Data Center

Kindly check the correctness of your credentials and ensure that the API token has been generated correctly and retry

Hope this helps and happy to assist further !!

Thank you very much and have a fantastic day!  
Warm regards

comments: author: rahul rajeev
body: Thank you for your response.  
But is the endpoint correct to generate the invitation link?


author: Andrii Maliuta
body: Hello [@rahul rajeev](/t5/user/viewprofilepage/user-id/5433114) ,

Do you get the 401 error for other REST API endpoints?

How did you get the '**rest/invitation/1.0/invitation-link****'** endpoint? It is not listed in the REST API docs <https://docs.atlassian.com/ConfluenceServer/rest/8.8.0/> for COnfluence Data Center/Server.

comments: author: rahul rajeev
body: Hi [@Andrii Maliuta](/t5/user/viewprofilepage/user-id/484201)   

Thank you for your response.  

Someone told me I could use this endpoint to invite. Is there any other way to regenerate user invitation link in confluence data center(8.5.5) automatically using bash script?


author: Humashankar VJ
body: Hi [@rahul rajeev](/t5/user/viewprofilepage/user-id/5433114)

Endpoint is certainly used to create invitation links for users

This endpoint giving hard time and not supporting in the process regenerating invitation links for existing users automatically

Try to regenerate invitation links for existing users automatically using a bash script which is a bit complex approach while comparing toward the API endpoint.

At this time we can treat this as a first level conclusion !!

If you intend to move forward, we can also work towards it.

Warm regards


author: rahul rajeev
body: Hi [@Humashankar VJ](/t5/user/viewprofilepage/user-id/5409474)

Thank you for your response. But at this point I dont want to create for existing users.  

I just want to generate new invitation links weekly for new users


author: Humashankar VJ
body: Yes - Endpoint looks perfect

comments: author: rahul rajeev
body: The endpoint is not working and I couldnt find in the Confluence documentation


Tags: confluence-data-center

data-center