2

We want to have a form in which a site member can request to add a team member, which is then automated.

In power automate we need the ID of the group:

/_api/web/sitegroups/GetByName('Test IRE Site Template Members')

This gives the data back with the ID and the group name, but how can I get the ID so I can use it in the next call to add the user to the group?

In the next REST API call I add the user by the following, having name_member comming in from the SharePoint List:

{"_metadata":{"type":"SP.User"},"loginName":"@{triggerOutputs()?['body/name_member/Claims']}"}

API response:

{
    "statusCode": 200,
    "headers": {
        "Transfer-Encoding": "chunked",
        "Vary": "Origin,Accept-Encoding",
        "X-SharePointHealthScore": "1",
        "X-SP-SERVERSTATE": "ReadOnly=0",
        "DATASERVICEVERSION": "3.0",
        "SPClientServiceRequestDuration": "14",
        "SPRequestGuid": "46ecf39f-1009-3000-295e-6c26effc6471",
        "request-id": "46ecf39f-1009-3000-295e-6c26effc6471",
        "MS-CV": "n/PsRgkQADApXmwm7/xkcQ.0",
        "Strict-Transport-Security": "max-age=31536000,max-age=31536000; includeSubDomains",
        "X-FRAME-OPTIONS": "SAMEORIGIN,DENY",
        "Content-Security-Policy": "frame-ancestors 'self' teams.microsoft.com *.teams.microsoft.com *.skype.com *.teams.microsoft.us local.teams.office.com *.powerapps.com *.yammer.com *.officeapps.live.com *.office.com *.stream.azure-test.net *.microsoftstream.com;",
        "MicrosoftSharePointTeamServices": "16.0.0.21715",
        "X-Content-Type-Options": "nosniff,nosniff",
        "X-MS-InvokeApp": "1; RequireReadOnly",
        "x-ms-request-id": "46ecf39f-1009-3000-295e-6c26effc6471",
        "Cache-Control": "no-store, max-age=0, private",
        "P3P": "CP=\"ALL IND DSP COR ADM CONo CUR CUSo IVAo IVDo PSA PSD TAI TELo OUR SAMo CNT COM INT NAV ONL PHY PRE PUR UNI\"",
        "Set-Cookie": "ARRAffinity=a703f806325944e1ff92f5b6964fbc06b4fdf5647d48c76a29966c392ea989b9;Path=/;HttpOnly;Secure;Domain=sharepointonline-ne.azconn-ne.p.azurewebsites.net,ARRAffinitySameSite=a703f806325944e1ff92f5b6964fbc06b4fdf5647d48c76a29966c392ea989b9;Path=/;HttpOnly;SameSite=None;Secure;Domain=sharepointonline-ne.azconn-ne.p.azurewebsites.net",
        "X-AspNet-Version": "4.0.30319",
        "X-Powered-By": "ASP.NET",
        "Timing-Allow-Origin": "*",
        "x-ms-apihub-cached-response": "true",
        "Date": "Tue, 28 Sep 2021 13:28:20 GMT",
        "Content-Type": "application/json; odata=verbose; charset=utf-8",
        "Expires": "Mon, 13 Sep 2021 13:28:20 GMT",
        "Last-Modified": "Tue, 28 Sep 2021 13:28:20 GMT",
        "Content-Length": "811"
    },
    "body": {
        "d": {
            "__metadata": {
                "id": "https://bamgroup.sharepoint.com/sites/025556/_api/Web/SiteGroups/GetById(5)",
                "uri": "https://bamgroup.sharepoint.com/sites/025556/_api/Web/SiteGroups/GetById(5)",
                "type": "SP.Group"
            },
            "Owner": {
                "__deferred": {
                    "uri": "https://bamgroup.sharepoint.com/sites/025556/_api/Web/SiteGroups/GetById(5)/Owner"
                }
            },
            "Users": {
                "__deferred": {
                    "uri": "https://bamgroup.sharepoint.com/sites/025556/_api/Web/SiteGroups/GetById(5)/Users"
                }
            },
            "Id": 5,
            "IsHiddenInUI": false,
            "LoginName": "Test IRE Site Template Members",
            "Title": "Test IRE Site Template Members",
            "PrincipalType": 8,
            "AllowMembersEditMembership": true,
            "AllowRequestToJoinLeave": false,
            "AutoAcceptRequestToJoinLeave": false,
            "Description": null,
            "OnlyAllowMembersViewMembership": false,
            "OwnerTitle": "Test IRE Site Template Owners",
            "RequestToJoinLeaveEmailSetting": ""
        }
    }
}

1 Answer 1

3

You can get the SharePoint group Id from API response (body) using Parse JSON action like below:

enter image description here

Send HTTP Request action configuration:

  • Method: GET
  • Uri:
_api/web/sitegroups/GetByName('Flow Owners')?$select=Title,Id

Where Flow Owners is group name.

Parse JSON action configuration:

  • Content: body from above action
  • Schema:
{
    "type": "object",
    "properties": {
        "d": {
            "type": "object",
            "properties": {
                "Id": {
                    "type": "integer"
                },
                "Title": {
                    "type": "string"
                }
            }
        }
    }
}

Output:

You can get SharePoint group ID in groupId variable like:

enter image description here

2
  • Thanks mate, I now get the Json parsing bit. Just couldn't get my head around that one. Q: Are you the Ganesh Sanap that works at TCS? Sep 28, 2021 at 19:04
  • No, I don't work at TCS. You can find more about me at here or see my SE profile. Sep 29, 2021 at 5:14

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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