2

I want to be able to add a custom column to a SharePoint library using Graph API.

I was able to create the library using article https://docs.microsoft.com/en-us/graph/api/list-create?view=graph-rest-1.0&tabs=http. But, I don't find any information on adding custom column after the library is created.

I tried to do PUT and PATCH operation but it throws 400 Bad Request. I also checked below article https://docs.microsoft.com/en-us/graph/api/listitem-update?view=graph-rest-1.0&tabs=http but it doesn't tell any way to adding a custom column.

1 Answer 1

2

Try with POST method like:

POST /sites/{site-id}/lists/{list-id}/columns

Example request:

POST https://graph.microsoft.com/beta/sites/{site-id}/lists/{list-id}/columns
Content-Type: application/json

{
  "description": "test",
  "enforceUniqueValues": false,
  "hidden": false,
  "indexed": false,
  "name": "Title",
  "text": {
    "allowMultipleLines": false,
    "appendChangesToExistingText": false,
    "linesForEditing": 0,
    "maxLength": 255
  }
}

Microsoft documentation: Create columnDefinition for a list


Note: Currently this is available for Microsoft Graph REST API Beta version.

2
  • Thank you! This was helpful and it created the column. Also I checked that v1.0 too creates the column but yesterday it was giving 400 Bad Request error. May be I had some issue with JSON. I used the JSON from the format above and it worked. Commented Jul 16, 2021 at 12:06
  • Great, glad it worked for you. Please Upvote(^) and accept as an Answer as it helped you & it will help others with similar question in future to find the correct answer easily. It also removes this question from "Unanswered questions" list. Commented Jul 16, 2021 at 12:15

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.