Skip to content

Commit a7107c0

Browse files
authored
Corrected code samples (SharePoint#8380)
Corrected code samples to include missing quotes
1 parent c8e9c74 commit a7107c0

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

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

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
title: Working with folders and files with REST
33
description: Perform basic create, read, update, and delete (CRUD) operations on folders and files with the SharePoint REST interface.
4-
ms.date: 06/07/2022
4+
ms.date: 08/18/2022
55
ms.prod: sharepoint
66
ms.localizationpriority: high
77
---
@@ -117,7 +117,7 @@ Authorization: "Bearer " + accessToken
117117
You can also **retrieve a file when you know its URL**, as in the following example.
118118

119119
```http
120-
GET https://{site_url}/_api/web/GetFileByServerRelativeUrl('/Folder Name/{file_name})/$value
120+
GET https://{site_url}/_api/web/GetFileByServerRelativeUrl('/Folder Name/{file_name}')/$value
121121
Authorization: "Bearer " + accessToken
122122
```
123123

@@ -201,7 +201,7 @@ The following example shows how to **update a file by using the PUT method**.
201201
> **PUT** is the only method that you can use to update a file. The **MERGE** method is not allowed.
202202
203203
```http
204-
POST https://{site_url}/_api/web/GetFileByServerRelativeUrl('/Folder Name/{file_name})/$value
204+
POST https://{site_url}/_api/web/GetFileByServerRelativeUrl('/Folder Name/{file_name}')/$value
205205
Authorization: "Bearer " + accessToken
206206
Content-Length: {length of request body as integer}
207207
X-HTTP-Method: "PUT"
@@ -270,11 +270,13 @@ function uploadFileBinary() {
270270
else {
271271
requestExecutor = new SP.RequestExecutor(document.getElementById("TxtWebUrl").value);
272272
}
273+
273274
var body = "";
274275
for (var i = 0; i < 1000; i++) {
275276
var ch = i % 256;
276277
body = body + String.fromCharCode(ch);
277278
}
279+
278280
var info = {
279281
url: "_api/web/lists/getByTitle('Shared Documents')/RootFolder/Files/Add(url='a.dat', overwrite=true)",
280282
method: "POST",
@@ -284,6 +286,7 @@ function uploadFileBinary() {
284286
error: fail,
285287
state: "Update"
286288
};
289+
287290
requestExecutor.executeAsync(info);
288291
}
289292

@@ -294,7 +297,7 @@ function uploadFileBinary() {
294297
The following example shows how to **retrieve all of the files that are attached to a list item**.
295298

296299
```http
297-
GET https://{site_url}/_api/web/lists/getbytitle('{list_title}')/items({item+id})/AttachmentFiles/
300+
GET https://{site_url}/_api/web/lists/getbytitle('{list_title}')/items({item_id})/AttachmentFiles/
298301
Authorization: "Bearer " + accessToken
299302
Accept: "application/json;odata=verbose"
300303
```

0 commit comments

Comments
 (0)