SharePoint Modern Power Automate Grant Access Using REST API - New Error

Tom Molskow 381 Reputation points
2023-07-19T20:14:29.27+00:00

Hello Community!

I have been working on an issue with a Power Automate workflow to automate granting access to users. I have received a lot of help from the community on this one and I hope this will be the last issue.

I have 3 actions:

  • Send an HTTP request to get User Principal ID
  • Initialize varUserPID variable
  • Send an HTTP request to Grant User Access

Here is the screen shot below:

User's image

The workflow builds without error, but when I run it I get this error:

The expression "lists/getByTitle('IDEA B Basic & Preschool Budgets Objective2')/items(6)/roleassignments/addroleassignment(principalid=body('Send_an_HTTP_request_to_SharePoint_to_get_User_Principal_ID')['d']['id'],roledefid=1073741830)" is not valid.

clientRequestId: 068ac05d-b3fe-4577-bee6-bb8885dbf484

serviceRequestId: 1d1fc8a0-c043-3000-fb2e-09c786b3c415

Here is the Raw Output:

{
    "host": {
        "connectionReferenceName": "shared_sharepointonline",
        "operationId": "HttpRequest"
    },
    "parameters": {
        "dataset": "https://nmgov.sharepoint.com/sites/IDEABGrant",
        "parameters/method": "POST",
        "parameters/uri": "_api/lists/getByTitle('IDEA B Basic & Preschool Budgets Objective2')/items(6)/roleassignments/addroleassignment(principalid=body('Send_an_HTTP_request_to_SharePoint_to_get_User_Principal_ID')['d']['id'],roledefid=1073741830)"
    }
}

According to the article below everything is configured correctly.

https://powerusers.microsoft.com/t5/Power-Automate-Community-Blog/Power-Automate-and-SharePoint-Permissions/ba-p/656216

Has anyone else seen and corrected this issue and if so please provide code examples and guidance.

Thanks!

Tom

SharePoint
SharePoint
A group of Microsoft Products and technologies used for sharing and managing content, knowledge, and applications.
10,026 questions
SharePoint Development
SharePoint Development
SharePoint: A group of Microsoft Products and technologies used for sharing and managing content, knowledge, and applications.Development: The process of researching, productizing, and refining new or existing technologies.
2,762 questions
0 comments No comments
{count} votes

Accepted answer
  1. ChengFeng - MSFT 5,015 Reputation points Microsoft Vendor
    2023-07-20T02:33:01.5066667+00:00

    Hi @Tom Molskow

    From the screenshot you provided, you output body('Send_an_HTTP_request_to_SharePoint_to_get_User_Principal_ID')['d']['id'] as text.User's image

    The formula should be put into Expression in this way, so that the ID in the return value of the request can be obtained through the formula

    User's image


    If the answer is helpful, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".

    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    Best Regards

    Cheng Feng

    1 person found this answer helpful.

0 additional answers

Sort by: Most helpful