ProcessQuery answers Invalid request. when the XML uses single-quoted attributes
Build CSOM request XML with double quotes around every attribute value. Single quotes are perfectly good XML and the natural choice inside a JavaScript string literal, but the ProcessQuery parser rejects them with HTTP 200 and a bare Invalid request. that points at nothing.
XML pro CSOM piš s dvojitými uvozovkami u všech atributů. Jednoduché uvozovky jsou platné XML a v řetězci v JavaScriptu se nabízejí samy, jenže parser ProcessQuery je odmítne – vrátí HTTP 200 a holé Invalid request., které neukazuje na nic konkrétního.
Symptom
A ProcessQuery call returns HTTP 200 and this body:
[{"SchemaVersion":"15.0.0.0","LibraryVersion":"16.0.27911.12005","ErrorInfo":{
"ErrorMessage":"Invalid request.","ErrorValue":null,
"TraceCorrelationId":"00000000-0000-0000-0000-000000000000","ErrorCode":-1,
"ErrorTypeName":"Microsoft.SharePoint.Client.ClientServiceException"},
"TraceCorrelationId":"00000000-0000-0000-0000-000000000000"}]
No action id, no object path id, no property name. The same request body copied into a file validates as XML.
Cause
The server-side parser for the client query protocol accepts attribute values in double quotes only. Written from JavaScript, single quotes are the obvious choice, because they let the XML keep its own double quotes:
// rejected
const xml = '<Method Name=\'Update\' Id=\'12\' ObjectPathId=\'3\' />';
The payload travels fine, the endpoint answers 200, and the failure arrives as a generic ClientServiceException inside the body.
Fix
Keep the double quotes in the XML and quote the JavaScript string differently:
// accepted
const xml = '<Method Name="Update" Id="12" ObjectPathId="3" />';
Measured A/B on SharePoint Online, same node, same payload, only the quote character swapped, three calls in a row:
| Attribute quoting | HTTP | ErrorInfo |
|---|---|---|
'single' |
200 | Invalid request. |
"double" |
200 | null — the change is applied |
'single' again |
200 | Invalid request. |
Notes
- CSOM reports failures inside an HTTP 200 body. Parse the response array and check
ErrorInfoon every element; a status check alone reports success for every one of these. Invalid request.is the parser's generic answer and does not name the quoting specifically — only the A/B above ties it to that. If double quotes do not clear it, look at the object-path graph next: everyIdhas to be unique across<Actions>and<ObjectPaths>, and everyObjectPathIdhas to point at anIdthat the same request declares.- Escape the values themselves (
&,<,>,") before you paste them into the XML; an unescaped one breaks the document before the client service gets to it.