docs: fix the 'list all items in a drive' sample (#1070) - #1572
Open
eduardarbona (earbona23) wants to merge 1 commit into
Open
docs: fix the 'list all items in a drive' sample (#1070)#1572eduardarbona (earbona23) wants to merge 1 commit into
eduardarbona (earbona23) wants to merge 1 commit 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.
Author
|
@microsoft-github-policy-service agree |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.