Overview
Modify an existing group
- REST Method: PUT
- Method Access: public
Uri Parameters
Name |
Type |
Description |
groupid |
string |
either an integer group ID or "=" followed by a double uri-encoded group name |
Query Parameters
Name |
Type |
Description |
authenticate |
bool? |
Force authentication for request (default: false) |
Return Codes
Name |
Value |
Description |
OK |
200 |
Request completed successfully |
Bad Request |
400 |
Invalid input parameter or request body |
Forbidden |
403 |
Administrator access is required |
Not Found |
404 |
Requested group could not be found |
Message Format
Input:
Output:
1 | < group id = "{int}" href = "{uri}" > |
3 | < service.authentication id = "{int}" href = "{uri}" /> |
4 | < users count = "{int}" href = "{uri}" /> |
6 | < operations mask = "{int}" >{text}</ operations > |
7 | < role id = "{int}" href = "{uri}" >{text}</ role > |
Implementation Notes
- This feature may be used for updating the group role and renaming the group.
- Use Post:groups/{groupid}/users to add and remove users from a group.
- The role name must match one of the roles defined by GET:site/roles.
- External groups may not be renamed
C# Sample: Modify a Group's Role
The following code example updates group with ID 2 to have the Contributor role:
Sample Code
2 | p.At( "users" , "authenticate" ).WithCredentials( "admin" , "password" ).Get(); |
3 | XDoc groupDoc = new XDoc( "group" ) |
4 | .Start( "permissions.group" ) |
5 | .Elem( "role" , "Contributor" ) |
7 | p.At( "groups" , "2" ).Put(groupDoc); |
Sample Response from executing Code
2 | < name >My Contributors Group</ name > |
6 | < operations mask = "1343" >LOGIN,BROWSE,READ,SUBSCRIBE,UPDATE,CREATE,DELETE,CHANGEPERMISSIONS</ operations > |
Implementation notes
Add notes about requirements or config values
Curl Sample: Modify a Group's Role
The following command sets a group's (group ID = 1) role to the one listed in "grouprole.xml".
Implementation notes
curl flags
- -u
- Basic HTTP authentication. Sends a username and password to server so it can verify whether a user is of privilege to perform specific operation.
- -H
- Adds a header or modifies an existing one. In this case, since an xml document is being sent, the content type must be set to "application/xml". The server will not accept the request otherwise.
- -T file
- Specifies a PUT request and XML document that contains the user data.
- -i
- Includes the HTTP response header in the output. Useful for debugging.
Permissions
- ADMIN permission is required to execute above command. Otherwise, a 403 HTTP response (Forbidden) will be returned.
Example
We want to modify the role of a group (group ID = 2) created here. Here are some of the roles that are packaged with Expert: Contributer, Viewer, Guest, and Admin. The group we wish to modify has the role of "Contributer". In this example, it will be changed to "Viewer".
fabfour.xml
Content-Type: application/xml
HTTP Response Headers
HTTP/1.1 200 OK
Date: Thu, 14 Jan 2010 19:48:33 GMT
Server: Dream-HTTPAPI/1.7.2.17433
X-Deki-Site: id="default"
Content-Type: application/xml; charset=utf-8
Content-Length: 449
Via: 1.1 dekiwiki
HTTP Response Body
Content-Type: application/xml
03 | < groupname >the fab four</ groupname > |
07 | < operations mask = "15" >LOGIN,BROWSE,READ,SUBSCRIBE</ operations > |