I am trying to add user to a SharePoint group in a "SharePoint Hosted App". First I am checking whether the user exists in that particular group or not. If not, I am trying to add that user to a group. But it is giving me the error as
A potentially dangerous Request.Path value was detected from the client (:).
What could be the issue? I am using REST query in SharePoint Online (Office 365). Here is my code:
function AddUserToGroup(groupid,userEmail,siteurl,userKey,userId) {
executor = new SP.RequestExecutor(appweburl);
executor.executeAsync({
url: appweburl + appweburl+"/_api/SP.AppContextSite(@target)/web/sitegroups("+groupid+")/users?@target='"+siteurl+"'",
method: "POST",
headers: { Accept: "application/json;odata=verbose", "content-type": "application/json;odata=verbose" },
body: "{ '__metadata': { 'type': 'SP.User' }, 'LoginName': 'i:0#.f|membership|"+userEmail+"' }",
success: AddUser_Success,
error: AddUser_Failure
});
}
I followed the example which was demonstrated in the MSDN site.