cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
Helper V
Helper V

How to replace permission for an individual user

I am using HTTP request (REST) to add/remove permissions for a user. I've got a point where I have stripped all permissions from a newly created item, then given an individual user Read. On subsequent flow I need to give the user Edit permissions for the same item. What would I put into the HTTP call to do that?

I've included a flow picture to show that I can get the created_by user, but how would I replace permissions without removing all existing permission on the item and then re-adding?!

fghfg.PNG

1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted
Frequent Visitor

Re: How to replace permission for an individual user

Hey Cardinalpipkin,

The below article has a great tutorial on this.  

https://sergeluca.wordpress.com/2018/05/03/assign-unique-permissions-to-a-document-with-the-new-send...

 

Although, personally I add/removed users from a group, rather than using individuals. So if you have a Owners, Contributor, and Visitor group, you'd add/remove the user from one of those groups. I wasn't able to utilize the getByEmail portion. Instead, I used their loginname, which looks like  i:0#.f|membership|user@contoso.com

 

What you will want to do is first send a get request to get the groupID of the targeted group.

Kamz_0-1600441558829.png

URI:

_api/web/SiteGroups?$filter=LoginName eq 'Site Group Name'&$select=Id&top=1 

*Note: Site Group Name would usually be the name of the site space Owners or Contributors. So example: Site name is Finance, you would put: Finance Owners


Then you will want to do a Parse JSON. Content should be the body of the Get request.

parse.JPG

Schema:

{
    "type": "object",
    "properties": {
        "d": {
            "type": "object",
            "properties": {
                "results": {
                    "type": "array",
                    "items": {
                        "type": "object",
                        "properties": {
                            "Id": {
                                "type": "integer"
                            },
                            "__metadata": {
                                "type": "object",
                                "properties": {
                                    "id": {
                                        "type": "string"
                                    },
                                    "uri": {
                                        "type": "string"
                                    },
                                    "type": {
                                        "type": "string"
                                    }
                                }
                            }
                        },
                        "required": [
                            "__metadata",
                            "Id"
                        ]
                    }
                }
            }
        }
    }
}

Finally, you will want to do a POST using the Id from the JSON parse

POST.JPG

Body:

{"__metadata":{"type":"SP.User"},"LoginName":"i:0#.f|membership|user@contoso.com"}  

 

 

If this solves your issue, please mark it as the solution

View solution in original post

2 REPLIES 2
Highlighted
Frequent Visitor

Re: How to replace permission for an individual user

Hey Cardinalpipkin,

The below article has a great tutorial on this.  

https://sergeluca.wordpress.com/2018/05/03/assign-unique-permissions-to-a-document-with-the-new-send...

 

Although, personally I add/removed users from a group, rather than using individuals. So if you have a Owners, Contributor, and Visitor group, you'd add/remove the user from one of those groups. I wasn't able to utilize the getByEmail portion. Instead, I used their loginname, which looks like  i:0#.f|membership|user@contoso.com

 

What you will want to do is first send a get request to get the groupID of the targeted group.

Kamz_0-1600441558829.png

URI:

_api/web/SiteGroups?$filter=LoginName eq 'Site Group Name'&$select=Id&top=1 

*Note: Site Group Name would usually be the name of the site space Owners or Contributors. So example: Site name is Finance, you would put: Finance Owners


Then you will want to do a Parse JSON. Content should be the body of the Get request.

parse.JPG

Schema:

{
    "type": "object",
    "properties": {
        "d": {
            "type": "object",
            "properties": {
                "results": {
                    "type": "array",
                    "items": {
                        "type": "object",
                        "properties": {
                            "Id": {
                                "type": "integer"
                            },
                            "__metadata": {
                                "type": "object",
                                "properties": {
                                    "id": {
                                        "type": "string"
                                    },
                                    "uri": {
                                        "type": "string"
                                    },
                                    "type": {
                                        "type": "string"
                                    }
                                }
                            }
                        },
                        "required": [
                            "__metadata",
                            "Id"
                        ]
                    }
                }
            }
        }
    }
}

Finally, you will want to do a POST using the Id from the JSON parse

POST.JPG

Body:

{"__metadata":{"type":"SP.User"},"LoginName":"i:0#.f|membership|user@contoso.com"}  

 

 

If this solves your issue, please mark it as the solution

View solution in original post

Highlighted
Helper V
Helper V

Re: How to replace permission for an individual user

I'll give this a go when I get a chance, in the meantime I'll consider it a Accepted Answer.

Helpful resources

Announcements
Community Conference

Power Platform Community Conference

Check out the on demand sessions that are available now!

Power Platform ISV Studio

Power Platform ISV Studio

ISV Studio is designed to become the go-to Power Platform destination for ISV’s to monitor & manage published applications.

Upcoming Events

Experience what’s next for Power Automate

See the latest Power Automate innovations, updates, and demos from the Microsoft Business Applications Launch Event.

Top Solution Authors
Top Kudoed Authors
Users online (6,636)