Forums

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

How to make Next-Gen project private using API?

Jiří Koutný
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
May 1, 2019

Hi,

is it possible to set Next-Gen project private using the API? I haven't found any way to achieve that.

The following code does not work:

curl --request PUT --url 'https://dsprojects.atlassian.net/rest/api/3/project/[ID]' \
--header 'Authorization: Basic [token]' \
--header 'Accept: application/json' \
--header 'Content-Type: application/json' \
--data '{
"isPrivate": "true"
}'

The "isPrivate" attribute is not recognized.

The strange thing is that the following code returns "isPrivate": "false" even though the project is private according to the Jira UI (Project Settings -> Details).

curl --request GET --url 'https://dsprojects.atlassian.net/rest/api/3/project/[ID]' \
--header 'Authorization: Basic [token]==' \
--header 'Accept: application/json'

 

Am I missing something here? Thanks

3 answers

1 accepted

1 vote
Answer accepted
Dario B
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
June 21, 2019

Hi @Jiří Koutný ,

I am adding a new answer since I have created a new Feature request for this issue and I have actually found a workaround to change a Next-Gen project access settings via REST API.

The feature request is the below one. Please  vote and watch it so that you will be updated on the progress:

 

As you can read in the Workaround section of above ticket:

There is an internal endpoint that you can currently use to change the project access setting but this is not documented, not supported and it can change without prior notice: /rest/internal/simplified/1.0/projects/PROJECT-ID/summary

In order to change the access settings you have to sent a PUT request to the /rest/internal/simplified/1.0/projects/PROJECT-ID/summary specifying:
accessLevel: "OPEN", "PRIVATE" or "LIMITED"
avatarId: avatar id of the project
key: project key
name: project name

 

Example:

  1. Call https://XXXXX.atlassian.net/rest/api/3/project endpoint to get project info:
    // https://xxxxxxxx.atlassian.net/rest/api/3/project
    
      {
        "expand": "description,lead,issueTypes,url,projectKeys,permissions",
        "self": "https://xxxxxx.atlassian.net/rest/api/3/project/10303",
        "id": "10303",
        "key": "TSMN",
        "name": "Test Scrum Migration NextGen",
    .....
    
  2. change the access settings to the above project by sending a PUT request to https://xxxxxxx.atlassian.net/rest/internal/simplified/1.0/projects/10303/summary:
    curl -u EMAIL:API-TOKEN -H "Accept: application/json" -H "Content-Type: application/json" -d '{"key": "TSMN", "name": "Test Scrum Migration NextGen", "avatarId": 10722, "accessLevel": "PRIVATE"}' -X PUT https://xxxxxxx.atlassian.net/rest/internal/simplified/1.0/projects/10303/summary
    
    {"returnUrl":"/browse/TSMN","id":10303,"key":"TSMN","name":"Test Scrum Migration NextGen","accessLevel":{"value":"PRIVATE","displayName":"Private","description":"Only people added to the project can create and edit issues. Issues in this project don't appear in search results.","iconName":"private"},"avatarId":10201}

 

I hope this helps.

 

Have a nice weekend.

Dario

0 votes
Christophe Mes November 10, 2022

The method from @Dario B still works like a charm! I have a webhook configured in Jira on 'Project Create', this connects to our automation platform (make.com), here we inject a ticket in Jira for IT support team to followup and finally we use the API call to set the project access to Private. It works on Jira software and Jira business (JWM) projects.


Screenshot 2022-11-10 at 18.38.26.png

0 votes
Dario B
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
June 21, 2019

Hi @Jiří Koutný ,

The value isPrivate returns true for any project in which the current user (the user account used to authenticate the REST API call) can’t browse issues.

In other words, that property just tells you whether you have permission to browse issues in the project and it is not intended  to be used to set the Next-Gen project to private.  

 

I hope this helps.

 

Cheers,
Dario

Suggest an answer

Log in or Sign up to answer