Just a heads up: On March 24, 2025, starting at 4:30pm CDT / 19:30 UTC, the site will be undergoing scheduled maintenance for a few hours. During this time, the site might be unavailable for a short while. Thanks for your patience.

×
Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

Create Group with Jira REST API

Lizhi Fan
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!
June 10, 2015

Hi, 

In the current documentation for Create Group in the JIRA Rest API: 

https://docs.atlassian.com/jira/REST/latest/#api/2/group-createGroup

I can't seem to find what to put in the payload or parameters for the POST command to /rest/api/2/group
I was wondering if I could get some help. 

Thanks!  

 

 

1 answer

1 accepted

1 vote
Answer accepted
Treethawat Thanawachiramate
Contributor
June 10, 2015

Hi,

Try this in your post method:

{"name": "GroupName"}

I test with REST API Browser and it work fine. I normally use the groovy script to do stuff with the API.

 

Here is my example:

import static groovyx.net.http.ContentType.*
import groovyx.net.http.HTTPBuilder
import groovy.sql.Sql
import static groovyx.net.http.Method.*

// JIRA Authorized user (Local)
JiraUsrName = ""        // JIRA Admin username
JiraPsw = ""            // JIRA Admin password

// JIRA API servers
def JIRAServer = "yourserver/jira"  // TheMan/jira (Do not put http)

println "" + System.getProperty("line.separator")
println "==============================="
println "Starting on: ${JIRAServer} Server"
println "==============================="

// Global Parameters
def httpAdd                      // Obj for the HTTPBuilder
def TestAddGroup = []            // Test Add Group
def Count = 0                    // Counter for loop

// Example data
TestAddGroup.add("ManTestAAA")
TestAddGroup.add("ManTestBBB")
TestAddGroup.add("ManTestCCC")

// JIRA Rest API
httpAdd = new HTTPBuilder("http://${JIRAServer}/rest/api/2/group")
httpAdd.headers['Authorization'] = 'Basic ' + "${JiraUsrName}:${JiraPsw}".getBytes('iso-8859-1').encodeBase64()

// If found any groups
if ( TestAddGroup.size() ){

    // Add JIRA user to the tempo-approval group through the Rest API
    println ""
    println "=== :Groups are Being Added: ==="
    while( Count < TestAddGroup.size() ){
        httpAdd.request(POST, JSON){
        
            // Parse JSON data
            body = [
                name: "'" + TestAddGroup[Count] + "'"
            ]
        
            response.success = { resp ->
        
                println "Success! ${resp.status} : Added ${TestAddGroup[Count]}"
                Count++
            }
        
            response.failure = { resp ->
                if (resp.status == 400) {
                    println "Request failed with status ${resp.status} : User requested an empty group name or group already exists"
                } else if (resp.status == 401) {
                    println "Request failed with status ${resp.status} : The current jira user is not authenticated"
                } else if (resp.status == 403) {
                    println "Request failed with status ${resp.status} : The current user does not have administrator permissions"
                } else if (resp.status == 500) {
                    println "Request failed with status ${resp.status} : Operation is not permitted or error occurs while creating the group"
                } else {
                    println "Error : Error code is not match or jira may down"
                }
                Count = TestAddGroup.size() + 1
            }
        }
    }
} else { // No user found to add

    println "=== :No group to add: ==="
}

 

 

Lizhi Fan
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!
June 11, 2015

Thanks so much! :)

G June 28, 2016

Do you have a groovy script to bulk create groups on JIRA?

Suggest an answer

Log in or Sign up to answer
TAGS
atlassian, atlassian government cloud, fedramp, webinar, register for webinar, atlassian cloud webinar, fedramp moderate offering, work faster with cloud

Unlocking the future with Atlassian Government Cloud ☁️

Atlassian Government Cloud has achieved FedRAMP Authorization at the Moderate level! Join our webinar to learn how you can accelerate mission success and move work forward faster in cloud, all while ensuring your critical data is secure.

Register Now
AUG Leaders

Upcoming Jira Events