The Atlassian Community Forums are currently in read-only mode. We will be relaunching on a new platform on September 22 (read more here). We apologize for the extended downtime. For concerns or questions, please email communitymanagers@atlassian.com. See you on the other side, on the new Atlassian Community Forums! :)

×

Forums

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

How to sync Jira and Confluence directories with API call ?

Rachid El Mansouri
May 3, 2023

Hi experts, 

I am trying to synchronize Jira and Confluence directories with an API call.

I wrote a powershell script but it is not working 

 

$TLS12Protocol = [System.Net.SecurityProtocolType] 'Ssl3 , Tls12'
[System.Net.ServicePointManager]::SecurityProtocol = $TLS12Protocol

$username = "toto"
$password = "xxxxx"
$baseurl = "https://myURL"

# Configuration de l'en-tête de la requête
$headers = @{
"Content-Type" = "application/json"
#"Authorization" = "Basic"
}

############### JIRA Synchro ##################
# Configuration de l'URL de l'API REST pour créer un projet
$jiraUrl = $baseurl + "/jira/plugins/servlet/embedded-crowd/directories/sync"
$directoryId = 10700

# Configuration des données du projet pour l'envoi à l'API REST
$syncBody = @{
"directoryId" = $directoryId
} | ConvertTo-Json


# Envoi de la requête à l'API REST pour créer le projet
$responseJira = Invoke-RestMethod -Uri $jiraUrl -Method Post -Headers $headers -Body $syncBody -Credential (New-Object System.Management.Automation.PSCredential ($username, (ConvertTo-SecureString $password -AsPlainText -Force)))

 I have an error 401 unauthorized 

 

Do you have an idea ?

2 answers

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

0 votes
Rachid El Mansouri
June 9, 2023

Any idea ?

0 votes
Fabio Racobaldo _Catworkx_
Community Champion
May 7, 2023

Hi @Rash ,

you can use JIRA as user management and syn users and groups in Confluence using a bultin feature (https://confluence.atlassian.com/doc/synchronizing-data-from-external-directories-229838498.html). Why don't you use this approach?

Fabio

Rachid El Mansouri
May 9, 2023

Hi @Fabio Racobaldo _Catworkx_ 

Thanks for your answer;

I can't use this approch because we use Crowd as user management. I want to sync Jira and Confluence after creation of new groups in Crowd.

I know that sync can be scheduled every x minutes but i want to automate it.

My initial need is to automate creation of new project (Group creation in Crowd, Jira directory sync, Jira project creation, Configuration of permissions in Jira project, Confluence space creation, Configuration of permissions in Confluence space...)

TAGS
AUG Leaders

Atlassian Community Events