Search code examples
microsoft-graph-apionedrivemicrosoft-graph-sdksmicrosoft-graph-files

OneDrive Graph API: Get User ID associated with drive ID


I have an ID of an OneDrive drive. Is there any way I can figure out the user ID to whom the OneDrive drive belongs to?


Solution

  • When you call

    GET /drives/{drive-id}
    

    it returns Drive resource type with Owner property. It's the user account that owns the drive and it includes user id.

    {
        "id": "b!t18F8ybsHUq1z3LTz8xvZqP8zaSWjkFNhsME-Fepo75dTf9vQKfeRblBZjoSQrd7",
        "driveType": "business",
        "owner": {
            "user": {
                "id": "efee1b77-fb3b-4f65-99d6-274c11914d12",
                "displayName": "John Doe"
            }
        },
        ...
    }