2

I'm trying to change the owner of a group via the REST API. I'm working entirely within the host web, so no cross domain calls from the app web. If I run the below code, it succeeds and changes the title of the group.

    $.ajax({
    url: "https://harepontsoce3.sharepoint.com/_api/Web/SiteGroups/GetById(62)",
    type: "MERGE",
    data: "{ '__metadata': { 'type': 'SP.Group' }, 'Title':'ABC333'",
    headers: {
        "accept": "application/json;odata=verbose",
        "content-type": "application/json;odata=verbose",
        "X-RequestDigest": $("#__REQUESTDIGEST").val(),
    }
}).done(function (data) { // end .ajax
    debugger;
    console.log("Done");
}).fail(function (error) {
    debugger;
    console.log(error.responseText);
});

However, when I add the 'Owner':{'Id':'6'} to the data payload, it still succeeds in that the .done callback is hit and I get no errors. But the title and owner are not changed.

    $.ajax({
    url: "https://areptsorce.sharepoint.com/_api/Web/SiteGroups/GetById(62)",
    type: "MERGE",
    data: "{ '__metadata': { 'type': 'SP.Group' }, 'Title':'ABC333', 'Owner':{'Id':'6'}}",
    headers: {
        "accept": "application/json;odata=verbose",
        "content-type": "application/json;odata=verbose",
        "X-RequestDigest": $("#__REQUESTDIGEST").val(),
    }
}).done(function (data) { // end .ajax
    debugger;
    console.log("Done");
}).fail(function (error) {
    debugger;
    console.log(error.responseText);
});

I have read other post the say you CAN NOT use REST to change the owner of a group and instead you need to use client.svc service and including an XML body. However, is does not make sense to me because of the following documentation directly from MS:

enter image description here

enter image description here

Everything in this documentation is telling me changing the group owner via REST is possible. What am I missing?

1
  • Did you ever solve this? Commented Jul 2, 2017 at 18:37

2 Answers 2

2

You aren't posting to the {owner} rest api, you're posting to the group api. You'll need to post the /sitegroups(id)/owner to change the user.

0

I was able to resolve this using information from the following article: https://www.sharepointeurope.com/set-a-sharepoint-group-owner-with-power-automate/

The request below works to add an existing 'SharePoint group' as the owner of another (newly created) SharePoint group within a SharePoint Communication Site:

enter image description here

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.