parthasarathy B

parthasarathy B

  • NA
  • 927
  • 107k

User not removing from group using Sharepoint rest API

Oct 9 2018 3:49 AM
Hi all,
         I am trying remove user from Sharepoint group using Rest API.I have tried the below code but it is not getting any error but the user is not removing from the group.Please help me to find out what i am doing wrong in the code.Thanks in advance.
 
principal ID is the ID of the user and roledefid is the id of the sharepoint contribute group 
 
  1. function revokePermission(webURL,listTitle,userID)  
  2. {  
  3.     debugger;  
  4.     try {  
  5.         var roleID=1073741827;  
  6.         jQuery.ajax({  
  7.             url: webURL + "/_api/Web/roleassignments/removeroleassignment(principalid="+userID+",roledefid="+roleID+")",  
  8.             method: "POST",  
  9.             headers: {   
  10.                 "Accept""application/json;odata=verbose",  
  11.                 "X-RequestDigest": $("#__REQUESTDIGEST").val(),  
  12.                 'X-HTTP-Method''DELETE'  
  13.             },  
  14.             success: function (data) {  
  15.                 debugger;  
  16.                 //var userGroups= data.d.Member;  
  17.                 //userGroups.deleteObject();  
  18.             },  
  19.             error: function (data) {  
  20.                 htmlContent+="";  
  21.                 console.log(data);  
  22.             }  
  23.         });  
  24.     } catch (e) {  
  25.         console.log(e);  
  26.     }  
  27. }  
 

Answers (8)