Repository navigation
docs: fix the 'list all items in a drive' sample (#1070) - #1572
Eduard Arbona (earbona23) wants to merge 2 commits into
Conversation
…microsoftgraph#365) Sample 3 called `client.drives.by_drive_id(id).items.get()`, i.e. `GET /drives/{id}/items`. That path is not an enumerable collection in Microsoft Graph — it addresses driveItems by id and only answers `$filter` queries — so the sample fails at runtime with `The 'filter' query option must be provided.` This has been reported repeatedly (microsoftgraph#365, closed without a fix, and microsoftgraph#1070 with nine reactions), while the broken sample stayed in the docs. Replace it with a correct, and now distinct, sample: enumerate every item in the drive by walking `root` with `delta`, paging through `odata_next_link`. That matches the section's title ("list ALL the items") and no longer overlaps with sample 6, which lists only the top level via `root/children`. A cross-reference between the two makes the distinction explicit. Verified against the generated SDK in this repo: `items.by_drive_item_id('root').delta`, its `with_url()` for paging, and `odata_next_link` / `value` on the delta response all exist. The snippet parses as valid Python.
|
@microsoft-github-policy-service agree |
|
A first check-in on this one: it has had no reviewer assigned since I opened it on 2 September, and the request list is empty, so I think it fell through rather than being held back. Still accurate today. On items = await client.drives.by_drive_id('DRIVE_ID').items.get()That is Gavin Barron (@gavinbarron), you have been merging non-generated PRs here recently — could you point this at whoever owns Two honest caveats, unchanged from the description: I did not run the snippet against a live drive, so the shape is verified against the generated request builders in this repo rather than against a tenant; and if these docs are meant to be generated from somewhere upstream rather than edited here, say so and I will close this and file it there instead. |
Fixes #1070 (and the earlier #365, which was closed without a fix).
The bug
Sample 3 in
docs/drives_samples.mdwas:GET /drives/{id}/itemsis not an enumerable collection in Microsoft Graph — itaddresses driveItems by id and only answers
$filterqueries — so following the samplereturns exactly the error nine people reacted to:
The SDK and Graph are both behaving correctly; the sample documented a call that cannot
work. #365 reported this and was closed with no fix while the broken sample stayed in place.
The fix
Sample 3 now does what its title says — list all the items — by walking
rootwithdeltaand paging throughodata_next_link:This also removes an overlap: as written, sample 3 duplicated sample 6 (which lists only the
top level via
root/children). Now 3 is the recursive listing and 6 is the top-level one,with a cross-reference between them so the distinction is explicit.
Verified against the generated SDK in this repo
items.by_drive_item_id('root').delta—msgraph/generated/drives/item/items/item/delta/delta_request_builder.py.with_url()for paging — same file, line 65odata_next_linkandvalueon the response — inherited fromBaseDeltaFunctionResponse(msgraph/generated/models/base_delta_function_response.py:18)Docs-only, one file. I did not run it against a live drive (no tenant), so if a maintainer
runs it and sees anything off with the paging, tell me and I will adjust — but every symbol
it uses is confirmed present in the generated client.