SharePointVault ~/gotchas/rest-api ⌕ Search 404 pages, error messages, scripts…Ctrl K ★ Star
M↓ README.mdM↓ invalid-text-value-is-a-maxlength-500.md
sharepoint-vault›gotchas›rest-api›invalid-text-value-is-a-maxlength-500.mdhistoryedit on GitHub
● GOTCHArest-api· 2 min read

"Invalid text value" (HTTP 500) means a Text column hit its 255-character limit

applies to: SharePoint Onlinereviewed: 2026-08-09#rest-api#lists#fields#diagnostics

Writing a string longer than a Text column's MaxLength fails with a generic HTTP 500 — Invalid text value. A text field contains invalid data. The response names no field, so in a multi-field write you cannot tell which one broke. Check TypeAsString/MaxLength before writing, and split the body to find the culprit.

Zápis řetězce delšího než MaxLength u pole typu Text skončí obecnou chybou HTTP 500, která neřekne, které pole je vinné. Před zápisem ověř typ a limit pole; při chybě rozděl tělo a zapisuj po polích.

Symptom

A MERGE that had worked for months starts failing after you lengthen one value:

POST /_api/web/lists/getbytitle('Products')/items(1)
X-HTTP-Method: MERGE
IF-MATCH: *
Content-Type: application/json;odata=nometadata

{ "PriceFrom": 1900, "PriceNote": "…450 characters…", "Variants": "[…]", "Specs": "[…]" }
{"odata.error":{"code":"-2130575336, Microsoft.SharePoint.SPException",
 "message":{"lang":"en-US","value":"Invalid text value.\n\nA text field contains invalid data. Please check the value and try again."}}}

Four fields in the body, one at fault, no hint which. The same payload with a shorter value succeeds.

Cause

The column was provisioned as single line of text (Text, MaxLength 255), not multiple lines of text (Note). In the list UI and in an item's JSON the two look identical — the limit only shows up on write, and SharePoint reports it with this catch-all message rather than a field-level validation error.

Note fields have no practical MaxLength (the property comes back empty), so anything long belongs there.

Rule

Check the schema before writing long values:

GET /_api/web/lists/getbytitle('Products')/fields
    ?$select=InternalName,TypeAsString,MaxLength&$filter=startswith(InternalName,'Price')
[{"InternalName":"PriceNote","TypeAsString":"Text","MaxLength":255},
 {"InternalName":"Specs","TypeAsString":"Note","MaxLength":null}]

When the 500 hits in a batched write, bisect. Send the fields one at a time (or in halves) — the failing one is identified in a couple of requests, versus guessing at four candidates. Worth automating in any provisioning or sync script that writes user-supplied text.

Related trap: the same generic 500 appears for a Choice column when the value contains characters the field rejects — so "Invalid text value" is a length or content problem in some text-ish column, never a transport problem. Don't retry it; the second attempt fails identically.

Was this helpful?ask or add your experience on GitHub →
Saved you an hour? A star on GitHub helps other SharePoint people find the vault.★ Star on GitHub
last reviewed: 2026-08-09last updated: 2026-09-24historyedit on GitHubview source