cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
smorley
Resolver III
Resolver III

Building a flow to populate a SharePoint Group

Hi everyone,

I'm following along this post:

https://powerusers.microsoft.com/t5/Power-Automate-Community-Blog/SharePoint-Group-Operations-in-Mic...

from  @siddarth_v

smorley_2-1647602909084.png

 

I'm getting stuck at the step where I assign the user to the group I created in the previous step.

 

smorley_0-1647602653834.png

When it runs, it appears like Id is undefined or empty.  When I do a compose statement on the Id, it is, in fact, empty.

 

This is the error message:

The expression "web/roleassignments/addroleassignment(principalid=, roledefid=1073741826)" is not valid.
clientRequestId: 59dc92bb-ad7f-479d-bdae-476bb179ce2b
serviceRequestId: 32ef2aa0-807d-1000-a49b-9448d00198c4

 

When I view the Parse JSON step above it shows the Id is 200.

smorley_1-1647602881894.png

Any thoughts as to what I should be using to collect the Id?

 

6 REPLIES 6
fchopo
Super User
Super User

Hi @smorley 

According to your screen capture, you have 2 "id" fields. Have you tried to use both?

Apart from that, can you check the json schema on the Parse Json action?

Regards,
Ferran

Did I answer your question? Please consider to mark my post as a solution to help others.
Proud to be a Flownaut!
smorley
Resolver III
Resolver III

Hi @fchopo , I have tried both Id fields.  

 

Here is the whole schema, which is rendering poorly in here:

{
"type": "object",
"properties": {
"type": {
"type": "string"
},
"properties": {
"type": "object",
"properties": {
"type": {
"type": "object",
"properties": {
"type": {
"type": "string"
}
}
},
"properties": {
"type": "object",
"properties": {
"type": {
"type": "string"
},
"properties": {
"type": "object",
"properties": {
"d": {
"type": "object",
"properties": {
"type": {
"type": "string"
},
"properties": {
"type": "object",
"properties": {
"type": {
"type": "object",
"properties": {
"type": {
"type": "string"
}
}
},
"properties": {
"type": "object",
"properties": {
"type": {
"type": "string"
},
"properties": {
"type": "object",
"properties": {
"results": {
"type": "object",
"properties": {
"type": {
"type": "string"
},
"properties": {
"type": "object",
"properties": {
"type": {
"type": "object",
"properties": {
"type": {
"type": "string"
}
}
},
"items": {
"type": "object",
"properties": {
"type": {
"type": "string"
},
"properties": {
"type": "object",
"properties": {
"type": {
"type": "object",
"properties": {
"type": {
"type": "string"
}
}
},
"properties": {
"type": "object",
"properties": {
"type": {
"type": "string"
},
"properties": {
"type": "object",
"properties": {
"__metadata": {
"type": "object",
"properties": {
"type": {
"type": "string"
},
"properties": {
"type": "object",
"properties": {
"type": {
"type": "object",
"properties": {
"type": {
"type": "string"
}
}
},
"properties": {
"type": "object",
"properties": {
"type": {
"type": "string"
},
"properties": {
"type": "object",
"properties": {
"id": {
"type": "object",
"properties": {
"type": {
"type": "string"
},
"properties": {
"type": "object",
"properties": {
"type": {
"type": "object",
"properties": {
"type": {
"type": "string"
}
}
}
}
}
}
},
"uri": {
"type": "object",
"properties": {
"type": {
"type": "string"
},
"properties": {
"type": "object",
"properties": {
"type": {
"type": "object",
"properties": {
"type": {
"type": "string"
}
}
}
}
}
}
},
"type": {
"type": "object",
"properties": {
"type": {
"type": "string"
},
"properties": {
"type": "object",
"properties": {
"type": {
"type": "object",
"properties": {
"type": {
"type": "string"
}
}
}
}
}
}
}
}
}
}
}
}
}
}
},
"Alerts": {
"type": "object",
"properties": {
"type": {
"type": "string"
},
"properties": {
"type": "object",
"properties": {
"type": {
"type": "object",
"properties": {
"type": {
"type": "string"
}
}
},
"properties": {
"type": "object",
"properties": {
"type": {
"type": "string"
},
"properties": {
"type": "object",
"properties": {
"__deferred": {
"type": "object",
"properties": {
"type": {
"type": "string"
},
"properties": {
"type": "object",
"properties": {
"type": {
"type": "object",
"properties": {
"type": {
"type": "string"
}
}
},
"properties": {
"type": "object",
"properties": {
"type": {
"type": "string"
},
"properties": {
"type": "object",
"properties": {
"uri": {
"type": "object",
"properties": {
"type": {
"type": "string"
},
"properties": {
"type": "object",
"properties": {
"type": {
"type": "object",
"properties": {
"type": {
"type": "string"
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
},
"Groups": {
"type": "object",
"properties": {
"type": {
"type": "string"
},
"properties": {
"type": "object",
"properties": {
"type": {
"type": "object",
"properties": {
"type": {
"type": "string"
}
}
},
"properties": {
"type": "object",
"properties": {
"type": {
"type": "string"
},
"properties": {
"type": "object",
"properties": {
"__deferred": {
"type": "object",
"properties": {
"type": {
"type": "string"
},
"properties": {
"type": "object",
"properties": {
"type": {
"type": "object",
"properties": {
"type": {
"type": "string"
}
}
},
"properties": {
"type": "object",
"properties": {
"type": {
"type": "string"
},
"properties": {
"type": "object",
"properties": {
"uri": {
"type": "object",
"properties": {
"type": {
"type": "string"
},
"properties": {
"type": "object",
"properties": {
"type": {
"type": "object",
"properties": {
"type": {
"type": "string"
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
},
"Id": {
"type": "object",
"properties": {
"type": {
"type": "string"
},
"properties": {
"type": "object",
"properties": {
"type": {
"type": "object",
"properties": {
"type": {
"type": "string"
}
}
}
}
}
}
},
"IsHiddenInUI": {
"type": "object",
"properties": {
"type": {
"type": "string"
},
"properties": {
"type": "object",
"properties": {
"type": {
"type": "object",
"properties": {
"type": {
"type": "string"
}
}
}
}
}
}
},
"LoginName": {
"type": "object",
"properties": {
"type": {
"type": "string"
},
"properties": {
"type": "object",
"properties": {
"type": {
"type": "object",
"properties": {
"type": {
"type": "string"
}
}
}
}
}
}
},
"Title": {
"type": "object",
"properties": {
"type": {
"type": "string"
},
"properties": {
"type": "object",
"properties": {
"type": {
"type": "object",
"properties": {
"type": {
"type": "string"
}
}
}
}
}
}
},
"PrincipalType": {
"type": "object",
"properties": {
"type": {
"type": "string"
},
"properties": {
"type": "object",
"properties": {
"type": {
"type": "object",
"properties": {
"type": {
"type": "string"
}
}
}
}
}
}
},
"Email": {
"type": "object",
"properties": {
"type": {
"type": "string"
},
"properties": {
"type": "object",
"properties": {
"type": {
"type": "object",
"properties": {
"type": {
"type": "string"
}
}
}
}
}
}
},
"IsEmailAuthenticationGuestUser": {
"type": "object",
"properties": {
"type": {
"type": "string"
},
"properties": {
"type": "object",
"properties": {
"type": {
"type": "object",
"properties": {
"type": {
"type": "string"
}
}
}
}
}
}
},
"IsShareByEmailGuestUser": {
"type": "object",
"properties": {
"type": {
"type": "string"
},
"properties": {
"type": "object",
"properties": {
"type": {
"type": "object",
"properties": {
"type": {
"type": "string"
}
}
}
}
}
}
},
"IsSiteAdmin": {
"type": "object",
"properties": {
"type": {
"type": "string"
},
"properties": {
"type": "object",
"properties": {
"type": {
"type": "object",
"properties": {
"type": {
"type": "string"
}
}
}
}
}
}
},
"UserId": {
"type": "object",
"properties": {
"type": {
"type": "string"
},
"properties": {
"type": "object",
"properties": {
"type": {
"type": "object",
"properties": {
"type": {
"type": "string"
}
}
},
"properties": {
"type": "object",
"properties": {
"type": {
"type": "string"
},
"properties": {
"type": "object",
"properties": {
"__metadata": {
"type": "object",
"properties": {
"type": {
"type": "string"
},
"properties": {
"type": "object",
"properties": {
"type": {
"type": "object",
"properties": {
"type": {
"type": "string"
}
}
},
"properties": {
"type": "object",
"properties": {
"type": {
"type": "string"
},
"properties": {
"type": "object",
"properties": {
"type": {
"type": "object",
"properties": {
"type": {
"type": "string"
},
"properties": {
"type": "object",
"properties": {
"type": {
"type": "object",
"properties": {
"type": {
"type": "string"
}
}
}
}
}
}
}
}
}
}
}
}
}
}
},
"NameId": {
"type": "object",
"properties": {
"type": {
"type": "string"
},
"properties": {
"type": "object",
"properties": {
"type": {
"type": "object",
"properties": {
"type": {
"type": "string"
}
}
}
}
}
}
},
"NameIdIssuer": {
"type": "object",
"properties": {
"type": {
"type": "string"
},
"properties": {
"type": "object",
"properties": {
"type": {
"type": "object",
"properties": {
"type": {
"type": "string"
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
},
"required": {
"type": "object",
"properties": {
"type": {
"type": "string"
},
"items": {
"type": "object",
"properties": {
"type": {
"type": "string"
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}

Based on this blog, https://knowhere365.space/microsoft-flow-create-a-new-sharepoint-group/ I added a variable and set it to: @{body('creategroup')['d']['Id']}

 

I added that variable to the send to http request step.

smorley_0-1647619762551.png

 

The error you get confirms that the Id value is empty:

Unable to process template language expressions in action 'Send_an_HTTP_request_to_SharePoint_Assign_Permission' inputs at line '0' and column '0': 'The template language expression 'body('creategroup')['d']['Id']' cannot be evaluated because property 'Id' doesn't exist, available properties are 'results'. 

fchopo
Super User
Super User

Maybe the expression should be 

body('creategroup')?['d']?['results']?['Id']'

Could you try it or paste the output of the http action (the one which creates the group?).

Hope it helps!

Ferran

Did I answer your question? Please consider to mark my post as a solution to help others.
Proud to be a Flownaut!

Hi @fchopo 

I got a little further by watching this video at about the 7-minute mark.  https://www.youtube.com/watch?v=kaxfnGdnzBo

The current sent http request looks like this:

smorley_0-1647870047932.png

From the video, the Method is POST.  When I do that I get an error.  

The property '__metadata' does not exist on type 'SP.Group'. Make sure to only use property names that are defined by the type.

When I use GET as the method, there is no error, but then it doesn't create the group.

smorley_1-1647870160872.png

 

smorley
Resolver III
Resolver III

A bit of an update @fchopo .  I got the POST method to work.  I'm going with the syntax is very picky.

 

 

 

As soon as I change the Title to a variable, the action times out with a "Bad Gateway" after retrying.

smorley_3-1647871212830.png

 

Helpful resources

Announcements
Power Automate News & Announcements

Power Automate News & Announcements

Keep up to date with current events and community announcements in the Power Automate community.

Community Calls Conversations

Community Calls Conversations

A great place where you can stay up to date with community calls and interact with the speakers.

Power Automate Community Blog

Power Automate Community Blog

Check out the latest Community Blog from the community!

Users online (5,803)