#files 17 articles
"File is missing" and "I cannot read the file" collapse into the same null — and the empty state then lies gotchas / rest-api A T | null helper folds 404, 403, 500 and network failure into one null, and the friendly empty state then lies to the one user who has overdue work; return {ok, status, data} and let only 404 (on every candidate path)… A # or % in a file or folder name — the classic …Url APIs cannot reach it, and the old writes quietly save %25 gotchas / rest-api The classic …ServerRelativeUrl lookups, Files/add(url=), folders/add, moveto and copyto cannot reach it even encoded: 404/400, Exists: false for a folder that exists, and writes that answer 200 but save a literal %25… A batch file move must be grouped by file, not by the record that points at it gotchas / rest-api When records share a file URL, iterating records moves it once and 404s on the rest; group by file, write the new URL to every record, and adopt a file already at the target on a rerun A file-size limit doesn't stop a zip bomb — Office extraction needs a decompressed cap gotchas / spfx An upload-size limit only bounds the compressed archive; a crafted !ref still OOMs the tab A folder's Files collection rejects a two-level $expand gotchas / rest-api ListItemAllFields/Editor 400s there; take ModifiedBy/Author from the file, and list one level through the folder API rather than a FileDirRef filter Don't trust the parsed-file-types table: SPO does full-text index .md gotchas / search The official table omits Markdown, yet live SPO full-text indexes it; probe before architecting encodeURIComponent won't save you from apostrophes in OData literals gotchas / rest-api encodeURIComponent leaves ' alone; double it File size in a document library — File_x0020_Size 400s; use $expand=File gotchas / rest-api File_x0020_Size 400s in $select; use File/Length File upload via /Files/add: nometadata works under OData v4 — an empty OData-Version breaks SPFx when you leave out Content-Type gotchas / rest-api nometadata + octet-stream under the default OData v4; an empty OData-Version without Content-Type throws inside SPHttpClient; plus the empty-filename mobile camera trap File versions come back oldest-first, so $top truncates the newest ones gotchas / rest-api /Versions is ascending, so $top drops the NEWEST ones; sorting the result descending afterwards hides it; $orderby=ID desc IS honoured together with $top (measured), and the list never contains the current version Markdown vs DOCX vs site pages: choosing a knowledge format for RAG on SharePoint guides Markdown vs DOCX vs site pages vs list items — extraction quality, token economics, and the author-here-publish-Markdown pattern moveto succeeds and your code reports a failure — action endpoints return an empty body gotchas / rest-api Action endpoints (moveto, removebyid) return an empty body, so response.json() throws after the operation happened and invites a retry; decide by status, parse only what you read Office files change their content hash when you PATCH metadata — property demotion gotchas / graph Metadata PATCH and copy jobs rewrite Office, .msg and .htm file bytes; key change detection on lastModifiedBy, never compare sizes exactly Previewing library files in your own app: every format behaves differently gotchas / spfx PDF embeds directly, Office needs WOPI by {UniqueId}, HTML is served as an attachment and never renders from src; SVG and HTML must never be framed from your own origin (uploader script runs in the viewer session) and… RecycleByID sends a file version to the recycle bin — DeleteByID does not gotchas / rest-api The two removal methods on /Versions differ: permanent vs. site recycle bin (ItemType 2, restorable); measured, with vid = major*512 + minor SharePoint's built-in PDF conversion endpoint works only with a plain fetch — auth headers break the redirect gotchas / rest-api _api/v2.0/drives/…/content?format=pdf converts Office files server-side with no Graph consent, but auth-decorating clients break its 302 to *.svc.ms; resolve the drive explicitly and guard on Content-Type What each format costs the model: tokens for the same content as .md, .docx, .pdf and a SharePoint page guides Real numbers: the same article as .md/.docx/.pdf/a SharePoint page — why extraction, not format, drives the token bill; plus a CZ-vs-EN language tax and a reproducible harness