Come for the products,
stay for the community

The Atlassian Community can help you and your team get more value out of Atlassian products and practices.

Atlassian Community about banner
4,296,845
Community Members
 
Community Events
165
Community Groups

Adding Users to group using rest API - Powershell

Edited

Hello,

I am running into an issue trying to call the Rest API Method using Powershell. I am sure I am calling the URL properly with my access token and other info. Although I am running into an issue. 

I have a script that can Grab the users ID and Group Id I want to add them too. The Last step is confusing me.

$gId = $group.groupId

$aId = $user.accountId

$Headers = @{"Authorization"="Basic $($authinfo)"}




$id = @{
          accountId = "$aId"
}

$body = $id | ConvertTo-Json




params = @{
Uri = "https://your-domain.atlassian.net/rest/api/3/group/user?groupId=$gId"
Method = 'POST'
Body = $body
ContentType = 'application/json'
}

Invoke-RestMethod @params -Headers $Headers

 

Output:

Invoke-RestMethod : The remote server returned an error: (400) Bad Request.

 

Changed URL to default - I replace my site in the script. 

2 answers

1 accepted

1 vote
Answer accepted

Not sure what the issue was. It started working the next day. Might be a limit how many times API is called? 

If I find the output of the Uri it is this:

https://company.atlassian.net/rest/api/3/group/user?groupId=8d402247-fec1-4f9a-a6f8-299bfe92cb83
{
"accountId": "5f31c34f1ac29c00458906f5"
}

 so the Account ID / group Ids should be valid. 

Suggest an answer

Log in or Sign up to answer
TAGS
Community showcase
Published in Confluence

Confluence: Where work and wellness meet

Feeling overwhelmed by the demands of work and life? With a 25% increase in the prevalence of anxiety and depression worldwide during the pandemic, for most of us, it’s a resounding yes . 🙋‍♀️ ...

1,052 views 19 29
Read article

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you