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

How to List children of a DriveItem with a known path using ms graph php sdk v2


I don't find how to list children of a DriveItem with a known path using ms graph php sdk v2.

GET /drives/{drive-id}/root:/{path-relative-to-root}:/children

The official documentation shows the endpoint but does not show how to translate that request into a function using the library.

how to make that kind of request using the chained functions of the library? Has anyone done something similar before? or do you have any clue for this?

I'm reviewing the source code of the library but I can't find any clues to resolve this.


Solution

  • The Graph SDK for C# has extension method itemWithPath, but I there is no PHP's equivalent at the moment.

    You can try some kind of hack for PHP by specifying the realtive path in byDriveItemId

    $graphServiceClient->drives()->byDriveId('driveId')->items()->byDriveItemId('root:/{path-relative-from-root}:')->children()->get()->wait();
    

    'root:/{path-relative-from-root}:' is without a slash / at the end. The slash should be added automatically by SDK.