2

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.

  • Did you fix the issue? I am also facing the similar issue of adding a user to group in SharePoint Online Hosted App. But, my code runs in App Domain but not in App Part. – Rare Solutions Mar 31 '15 at 0:19
1

Remove the extra "appweburl" on line 4. Your URL will look like "http://servername.comhttp://servername.com/api...." doing it the way you have posted.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.