-
Notifications
You must be signed in to change notification settings - Fork 1k
Description
Target SharePoint environment
SharePoint Online
What SharePoint development model, framework, SDK or API is this about?
SharePoint REST API
Developer environment
Windows
What browser(s) / client(s) have you tested
- 💥 Internet Explorer
- 💥 Microsoft Edge
- 💥 Google Chrome
- 💥 FireFox
- 💥 Safari
- mobile (iOS/iPadOS)
- mobile (Android)
- not applicable
- other (enter in the "Additional environment details" area below)
Additional environment details
Calling the SP API via the Power Automate action "Send an HTTP request to SharePoint"
Describe the bug / error
Using the following URI:
https://tenant.sharepoint.com/teams/LibraryName/_api/web/GetFileByServerRelativeUrl('/teams/LibraryName/Shared%20Documents/General/TestFile.txt')/versions(512)/$value
The API call fails with the following error:
"body": { "status": 400, "message": "Cannot write the value 'null' in raw format.\r\nclientRequestId: 69c173cf-acca-422b-9f3a-79a83616ddb7\r\nserviceRequestId: 099cd1a1-10af-a000-801f-818442e1a307", "source": "https://tenant.sharepoint.com/teams/LibraryName/_api/web/GetFileByServerRelativeUrl('/teams/LibraryName/Shared%20Documents/General/TestFile.txt')/versions(512)/$value", "errors": [ "-1", "Microsoft.Data.OData.ODataException" ] }
This failure only occurs on files that do not have multiple versions, in other words where the version in the library is the original upload. It works as expected in the same folder for files with multiple versions.
When running automation to gather v1.0 files in a directory, the API will work on files with multiple versions and fail on files where v1.0 is the only version.
Steps to reproduce
- Have a SP directory with files that have multiple versions and files that are the original upload with no subsequent versions
- Run a script that gathers a list of the files in the directory, then loops through each file calling this API to get v1.0 of each file
- Observe returned values from API calls are failures for files without multiple versions
Expected behavior
Expected behavior would be to return file content for all v1.0 files even if v1.0 is the only version.