Reputation: 57
Sample payload:
{
"text": {
"maxLength": 1000
}
}
And my PATCH Url is https://graph.microsoft.com/v1.0/sites/my-site-id/lists/my-list-id/columns/my-column-id
I am providing the usual headers Accept: application/json Content-Type: application/json And Authorization: Bearer Token....
I get BadRequest error
{
"error": {
"code": "invalidRequest",
"message": "One of the provided arguments is not acceptable.",
"innerError": {
"code": "badArgument",
"date": "2023-01-30T16:34:49",
"request-id": "b63137f9-fda0-41b7-9549-5952b5c89427",
"client-request-id": "b63137f9-fda0-41b7-9549-5952b5c89427"
}
}
}
I tried adding "propagateChanges": true to the payload and I get slightly different error
{
"error": {
"code": "invalidRequest",
"message": "Invalid request",
"innerError": {
"date": "2023-01-30T16:39:37",
"request-id": "41ca6541-6097-45c6-9418-d1cf57272d2c",
"client-request-id": "41ca6541-6097-45c6-9418-d1cf57272d2c"
}
}
}
Any help is appreciated.
NOTE: I am able to update for e.g. Description of the column, but not the text.maxLength property.
Upvotes: 0
Views: 624
Reputation: 20823
If you have textColumn and allowMultipleLines
is set to false
then you have one line text
column and the maximum length is 255.
It's not possible to change column type from one line text
to multiple lines text
via Graph API.
Call
PATCH https://graph.microsoft.com/v1.0/sites/my-site-id/lists/my-list-id/columns/my-column-id
{
"text": {
"allowMultipleLines": true,
"appendChangesToExistingText": false,
"linesForEditing": 6,
"textType": "plain"
}
}
Will fail.
You have to create a new column and define it as multiple lines. Define textColumn
and set allowMultipleLines
to true
.
POST https://graph.microsoft.com/v1.0/sites/my-site-id/lists/my-list-id/columns
{
"description": "",
"displayName": "Column XXX",
"enforceUniqueValues": false,
"hidden": false,
"indexed": false,
"name": "My new multiple lines column",
"readOnly": false,
"required": false,
"text": {
"allowMultipleLines": true,
"appendChangesToExistingText": false,
"linesForEditing": 6,
"textType": "plain"
}
}
Upvotes: 0
Reputation: 12245
The maximum length of a SharePoint text field type is 255, you cannot set it to 1000. If you try setting the max length to 200 for example instead of 1000, your query should succeed.
To allow longer strings, you have to use the "note" ("multiline text") field type, not "text". This one has a limit of 63,999.
I am not sure if you can change column type using graph api (you cannot as far as I remember, but I am not 100% sure), you may need to re-create that column as "multiline", change manually, use the classic rest api instead of graph api to do it programmatically, or something like a powershell script.
Upvotes: 0