Add Group Members via API
Has anyone had success adding Group Members via API (not being a system admin but having Group Management permissions)?
Answers
-
@Leibel S Yes it should be fairly easy to accomplish. need to get the group ID and have the users email address at least. The link below should take you to the documentation for adding a user to a group. You have to have group administrator or system administrator permissions.
Smartsheet - Official API and SDK Documentation (redoc.ly)
-
I am trying to get it done as a group admin (not a system admin) but it is not working. Have you ever done it as a group admin only?
-
@Leibel S I have not, I am a system admin. Are you getting an error when you run it? What's your return message?
-
Says not authorized.
{ "errorCode": 1004, "message": "You are not authorized to perform this action.", "refId": "asdasdasd" }
Sent in to support and they are telling me my format is wrong.
Thoughts?
-
@Leibel S what does your call look like? can you send a screenshot of that minus api token
-
URI
https://api.smartsheet.com/2.0/groups/{id}/members
Headers
{ "Authorization": "*TOKEN*", "Content-Type": "application/json" }
Body:
[ { "email": "email@email.com" } ]
-
Hi @Leibel S
I checked in with Support about this and they said they've been in touch with more information. It looks like the data body formatting requires a \ symbol to wrap around the data fields.
For example, using cURL:
curl -X POST "https://api.smartsheet.com/2.0/groups/xxxx/members" -H "Authorization: Bearer *TOKEN*" -H "Content-Type: application/json" -d "[{ \"email\": \"emailaddress@testing.com\" }]"
The cURL documentation does not clarify this. Thank you for pointing out the inconsistency! If this still hasn't helped, please continue to troubleshoot with Support so you can share information 1:1 in a private channel.
Cheers,
Genevieve
Need more help? 👀 | Help and Learning Center
こんにちは (Konnichiwa), Hallo, Hola, Bonjour, Olá, Ciao! 👋 | Global Discussions
-
I tried the slashes.
The 'slash' would end up doing nothing once it is received by the server (its read as an escape character but because the server is expecting a json object it ends up the same in the end).
@Samuel Mueller have you ever had to put in a 'slash'?
-
to add to my previous comment:
If the problem was the format it would give an 1008 error code (HTTP 400)
-
There have been situations where I have needed a slash, depends on what program and code I'm using.
What are you using? I generally use powershell and a rest method and this is an example of that code:
$headers = New-Object "System.Collections.Generic.Dictionary[[String],[String]]" $headers.Add("Content-Type", "application/json") $headers.Add("Authorization", "Bearer xxxxxxxx") $body = "{ `n `"email`": `"email.email@email.com`" `n}" $response = Invoke-RestMethod 'https://api.smartsheet.com/2.0/groups/xxxxxx/members' -Method 'POST' -Headers $headers -Body $body
-
or this
$headers = New-Object "System.Collections.Generic.Dictionary[[String],[String]]" $headers.Add("Content-Type", "application/json") $headers.Add("Authorization", "Bearer xxxxxxxx") $body = '{"email": "email.email@email.com"}' $response = Invoke-RestMethod 'https://api.smartsheet.com/2.0/groups/xxxxxx/members' -Method 'POST' -Headers $headers -Body $body
-
@Leibel S do you have a postman account? It's an easy way to confirm your code and you can convert the code to pretty much any language.
-
@Samuel Mueller My posts are all the same as yours.
Seems pretty clear that this is a bug in the permissions rule.
-
@Leibel S could be. Best option may be to have a system admin run your same code with their token and see if it works.
-
Are you able to get the groups?
Categories
- All Categories
- 14 Welcome to the Community
- Customer Resources
- 64.9K Get Help
- 439 Global Discussions
- 138 Industry Talk
- 470 Announcements
- 4.9K Ideas & Feature Requests
- 129 Brandfolder
- 148 Just for fun
- 67 Community Job Board
- 486 Show & Tell
- 33 Member Spotlight
- 2 SmartStories
- 300 Events
- 36 Webinars
- 7.3K Forum Archives