Why a sharepoint REST API to get SharedWithUsersId property form a folder returns Ids of previous shares?

ESTELLES DASI, FRANCISCO JAVIER 0 Reputation points
2023-05-05T12:39:26.67+00:00

I am trying to get the ids of users who have shared access to a folder but I am getting user ids even though they no longer have access. The call I make is

https://{URLSite}/_api/web/GetFolderByServerRelativeUrl('{FolderName}')/ListItemAllFields/SharedWithUsersId

This call returns me:

"body": {
        "d": {
            "SharedWithUsersId": {
                "__metadata": {
                    "type": "Collection(Edm.Int32)"
                },
                "results": [
                    14,
                    11
                ]
            }
        }

but the id's presents in results, no longer have access.

SharePoint
SharePoint
A group of Microsoft Products and technologies used for sharing and managing content, knowledge, and applications.
10,073 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. RaytheonXie_MSFT 32,801 Reputation points Microsoft Vendor
    2023-05-08T02:00:53.7733333+00:00

    Hi @ESTELLES DASI, FRANCISCO JAVIER

    Per my test, I can retrieve the same result with yours.

    User's image

    This api will return all the users you shared with although some of them are expired. Since you have shared folder with users, the user will exist in SharedWithUsers. You can use GetSharingInformation to retrieve Expiration. Please refer to following api

    _api/web/Lists(<guid>)/GetItemById(<itemid>)/GetSharingInformation?$Expand=permissionsInformation,pickerSettings
    
    

    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.