Skip to content

Commit 045f61f

Browse files
BobGermanVesaJuvonen
authored andcommitted
Fixed documentation on updating (renaming) a folder. Previous example… (SharePoint#2816)
* Fixed documentation on updating (renaming) a folder. Previous example, "update a folder with Merge method" did not work. * Update - should have updated the list item not the folder
1 parent 13e8f20 commit 045f61f

File tree

1 file changed

+18
-3
lines changed

1 file changed

+18
-3
lines changed

docs/sp-add-ins/working-with-folders-and-files-with-rest.md

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -59,12 +59,27 @@ Headers:
5959

6060
<br/>
6161

62-
The following example shows how to **update a folder by using the MERGE method**.
62+
The following example shows how to **rename a folder by using the MERGE method**.
63+
64+
First, obtain the folder's OData type with a GET request.
6365

6466
```
65-
url: http://site url/_api/web/GetFolderByServerRelativeUrl('/Folder Name')
67+
url: http://site url/_api/web/GetFolderByServerRelativeUrl('/Folder Name')/ListItemAllFields
68+
method: GET
69+
Headers:
70+
Authorization: "Bearer " + accessToken
71+
"IF-MATCH": etag or "*"
72+
accept: "application/json;odata=verbose"
73+
content-type: "application/json;odata=verbose"
74+
```
75+
76+
From the result, obtain the odata.type value, such as SP.Data.Shared_x0020_DocumentsItem (the value may be different depending on your library configuration). Then issue a MERGE
77+
78+
79+
```
80+
url: http://site url/_api/web/GetFolderByServerRelativeUrl('/Folder Name')/ListItemAllFields
6681
method: POST
67-
body: { '__metadata': { 'type': 'SP.Folder' }, 'Name': 'New name' }
82+
body: { '__metadata': { 'type': '(odata.type from previous call)' }, 'Title': 'New name', 'FileLeafRef': 'New name' }
6883
Headers:
6984
Authorization: "Bearer " + accessToken
7085
X-RequestDigest: form digest value

0 commit comments

Comments
 (0)