Update a OneDrive File and Verify the Write
A 4-step recipe with Microsoft Office. We can help you get access.
Recipe · 4 steps
Update a OneDrive File and Verify the Write
with Microsoft Office
Safely replace the content of an existing OneDrive file and confirm the result.
- Read the driveItem before writing so the caller records the pre-update size and lastModifiedDateTime to compare against after the upload.
- Download the current bytes before they are overwritten so the caller can restore the previous version if the update is later rejected.
- Replace the item's content with the supplied bytes. Graph returns the updated driveItem describing the newly written file.
- Read the item back as an independent confirmation that the write is durable and that lastModifiedDateTime advanced past the pre-update stamp.
What you'll need to have ready
- itemId: The id of the existing driveItem whose content is replaced.
- fileContent: The replacement file content uploaded as an octet-stream body. This PUT replaces the item's content in full; it is not a partial patch.
For your developer
Arazzo workflow microsoft-office:drive-file-update-roundtrip, 4 operations: getMyDriveItem → downloadMyDriveItemContent → uploadMyDriveItemContent → getMyDriveItem. Specs on APIs.io.