
11,696 questions
This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
I am creating folders in Sharepoint then trying to add folder properties via the MS API. I have no issue creating the folder but can't seem to figure out how to add the folder properties. Any help is appreciated.
Here are few steps how to do it:
POST
method and the endpoint _api/web/folders
to create a folder in the library. You need to specify the ServerRelativeUrl
of the folder in the request body. For example, if you want to create a folder named Test
in the Documents
library, the request body would be: {
"__metadata": {
"type": "SP.Folder"
},
"ServerRelativeUrl": "/Documents/Test"
}
GET
method and the endpoint _api/web/GetFolderByServerRelativeUrl('Folder Name')/ListItemAllFields
to get the folder’s list item properties. You need to replace Folder Name
with the actual folder name. For example, if you want to get the properties of the Test
folder, the endpoint would be: _api/web/GetFolderByServerRelativeUrl('Test')/ListItemAllFields
POST
method and the endpoint _api/web/GetFolderByServerRelativeUrl('Folder Name')/ListItemAllFields
to update the folder’s list item properties. You need to specify the __metadata
and the properties you want to update in the request body. You also need to use the MERGE
method and the If-Match
header to avoid conflicts. For example, if you want to update the Title
and the Description
properties of the Test
folder, the request body and headers would be: {
"__metadata": {
"type": "SP.Data.DocumentsItem"
},
"Title": "Test Folder",
"Description": "This is a test folder"
}
X-HTTP-Method: MERGE
If-Match: *