REST API remove/delete SP User from Group

Hello together,

i like to remove a SharePoint User from a SharePoint Group with a SharePoint Workflow with the REST API.

With a workflow i can already create users over the rest api in groups.

But i could not find any helpful post which gives me a howto for delete users from a group.

I am using the designer 2013 for creating. Is there a option for delete users?

Please help me.

I found this informations:

URL:

https://URL/subsite/_api/Web/GetUserById(17)/Groups"

headers:

accept: application/json; odata=verbose

content-type: application/json; odata=verbose

IF-MATCH: *

X-HTTP-Method: DELETE

FUNCTION:

http requst: POST


What is wrong?

Thanks





  • Edited by westede 19 hours 0 minutes ago
May 29th, 2015 8:30am

You can use the RemoveByLoginName method of the UserCollection. Here is a working example using jQuery.

function removeGroupMember() {
   appweburl = decodeURIComponent(getQueryStringParameter('SPAppWebUrl'));
    hostweburl = decodeURIComponent(getQueryStringParameter('SPHostUrl'));
    var urlTemplate = appweburl + "/_api/SP.AppContextSite(@target)/web/sitegroups/getbyname('coolgroup')/Users/removeByLoginName?@target='" + hostweburl + "'";

    $.ajax(
    {
         'url': urlTemplate,
         'method': 'POST',
         'data': JSON.stringify({
             'loginName': 'i:0#.w|domain\\user'
         }),
         'headers': {
             'accept': 'application/json;odata=verbose',
             'content-type': 'application/json;odata=verbose',
             'X-RequestDigest': $('#__REQUESTDIGEST').val()
         },
         'success': function (data) {
             var d = data;
         },
         'error': function (err) {
             alert(JSON.stringify(err));
         }
    }
  );


}

Free Windows Admin Tool Kit Click here and download it now
May 29th, 2015 11:26am

Thanks a lot... I am going to try it on monday. I Hope i could put it workful in the SharePoint Designer 2013 Workflow. Nice Weekend.
May 29th, 2015 12:44pm

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics