Forum Discussion
carvalhodouglaspereira
Aug 23, 2022Copper Contributor
I can't find the DRIVE-ITEM-ID
Hello how are you? I managed the most complicated steps that would be authentication, but what I believed to be the easiest became an even greater challenge. When I access the graph developer...
FeyitzaKangai
Sep 08, 2022Copper Contributor
carvalhodouglaspereira please check the queries below and see which one will help you. If you already have the drives id then you can use the children property to navigate to the excel workbook you are looking for. Remember to specify the strings in single quotes when subtituting where-object with $filter query e.g
https://graph.microsoft.com/v1.0/drives?$filter=createdBy/user/email eq '<your-email>'
And also make sure you have the requisite permissions as documented https://docs.microsoft.com/en-us/graph/api/drive-list?view=graph-rest-1.0&tabs=http
$drive = <Invoke graph endpoint> -Uri "drives" |
Where-Object { $_.createdBy.user.email -eq $user.email } |
Select-Object -First 1
$demoFilesFolder = <Invoke graph endpoint> -Uri "drives/$($drive.id)/root/children" |
Where-Object { $_.name -eq "Demo Files" } |
Select-Object -First 1 #optional
$driveItem = <Invoke graph endpoint> -Uri "drives/$($drive.id)/items/$($demoFilesFolder.id)/children" |
Where-Object { $_.name -eq "your-workbookname.xlsx" } |
Select-Object -First 1 #optional
- FeyitzaKangaiSep 08, 2022Copper ContributorHere are more endpoints that could be of use to you
# Use this endpoint to upload an excel workbook that already exists.
$driveItem = <Request-Resource-with-delegated-perms> -Uri "me/drive/root:/$($uploadFileName):/content" -Method "PUT" -FilePath $workbookFilePath -PermissionNeeded "Files.ReadWrite.All"
# NB: In above no need to check the existence of driveItem, as it will be created if it does not exist
# if it exists, it will just generate a new version.
$worksheet = <Request-Resource-with-delegated-perms> -Uri "me/drive/items/$($driveItem.id)/workbook/worksheets" -PermissionNeeded "Files.Read" |
Where-Object { $_.name -eq "Sheet1" } |
Select-Object -First 1
$driveItemWorkbookTable = <Request-Resource-with-delegated-perms> -Uri "me/drive/items/$($driveItem.id)/workbook/tables" -PermissionNeeded "Files.Read" |
Where-Object { $_.name -eq "Table1" } |
Select-Object -First 1
$tableColumn = <Request-Resource-with-delegated-perms> -Uri "me/drive/items/$($driveItem.id)/workbook/tables/$($driveItemWorkbookTable.id)/columns" -PermissionNeeded "Files.Read" |
Select-Object -First 1
$tableRow = <Request-Resource-with-delegated-perms> -Uri "me/drive/items/$($driveItem.id)/workbook/tables/$($driveItemWorkbookTable.id)/rows" -PermissionNeeded "Files.Read" |
Select-Object -First 1