Events
Mar 17, 9 PM - Mar 21, 10 AM
Join the meetup series to build scalable AI solutions based on real-world use cases with fellow developers and experts.
Register nowThis browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
Namespace: microsoft.graph
Important
APIs under the /beta
version in Microsoft Graph are subject to change. Use of these APIs in production applications is not supported. To determine whether an API is available in v1.0, use the Version selector.
Provide the contents of a new file or update the contents of an existing file in a single API call. This method only supports files up to 250 MB in size.
To upload large files, see Upload large files with an upload session.
This API is available in the following national cloud deployments.
Global service | US Government L4 | US Government L5 (DOD) | China operated by 21Vianet |
---|---|---|---|
✅ | ✅ | ✅ | ✅ |
Choose the permission or permissions marked as least privileged for this API. Use a higher privileged permission or permissions only if your app requires it. For details about delegated and application permissions, see Permission types. To learn more about these permissions, see the permissions reference.
Permission type | Least privileged permissions | Higher privileged permissions |
---|---|---|
Delegated (work or school account) | Files.ReadWrite | Files.ReadWrite.All, Sites.ReadWrite.All |
Delegated (personal Microsoft account) | Files.ReadWrite | Files.ReadWrite.All |
Application | Files.ReadWrite.All | Sites.ReadWrite.All |
PUT /drives/{drive-id}/items/{item-id}/content
PUT /groups/{group-id}/drive/items/{item-id}/content
PUT /me/drive/items/{item-id}/content
PUT /sites/{site-id}/drive/items/{item-id}/content
PUT /users/{user-id}/drive/items/{item-id}/content
PUT /drives/{drive-id}/items/{parent-id}:/{filename}:/content
PUT /groups/{group-id}/drive/items/{parent-id}:/{filename}:/content
PUT /me/drive/items/{parent-id}:/{filename}:/content
PUT /sites/{site-id}/drive/items/{parent-id}:/{filename}:/content
PUT /users/{user-id}/drive/items/{parent-id}:/{filename}:/content
The contents of the request body should be the binary stream of the file to be uploaded.
If successful, this method returns a driveItem object in the response body for the newly created or updated file.
This example uploads the string "The contents of the file goes here." to a file in the signed-in user's drive under FolderA named FileB.txt.
PUT https://graph.microsoft.com/beta/me/drive/root:/FolderA/FileB.txt:/content
Content-Type: text/plain
The contents of the file goes here.
If successful, this method returns an driveItem resource in the response body for the newly created or updated file.
HTTP/1.1 200 OK
Content-Type: application/json
{
"id": "0123456789abc",
"name": "FileB.txt",
"size": 35,
"file": { }
}
This example replaces the contents of a file with a known ID.
PUT https://graph.microsoft.com/beta/me/drive/items/{item-id}/content
Content-Type: text/plain
The contents of the file goes here.
If successful, this method returns an driveItem resource in the response body for the newly created file.
HTTP/1.1 201 Created
Content-Type: application/json
{
"id": "0123456789abc",
"name": "FileB.txt",
"size": 35,
"file": { }
}
See Error Responses for details about how errors are returned.
Events
Mar 17, 9 PM - Mar 21, 10 AM
Join the meetup series to build scalable AI solutions based on real-world use cases with fellow developers and experts.
Register now