-
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?
other (enter in the "Additional environment details" area below)
Developer environment
None
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
- browser version Chrome 128.0.6613.138
- SharePoint Modern Experience
Describe the bug / error
We are using the Graph API / CSOM to effectively replace an existing file with a stub/link file.
This uses the following Graph API endpoints:
-
Renames "Filename.docx" to "Filename.docx.url"
PATCH /drives/{drive-id}/items/{item-id} (docs) -
Replaces the file content with the URL Shortcut contents
PUT /drives/{drive-id}/items/{item-id}/content (docs) -
Deletes all previous version history via CSOM
ListItem.Versions.DeleteAll()
We observe that the Document Library does a reload of the contents and shows the updated file.
However, clicking to view the file behaves differently until the full browser page is refreshed.
For example, the URL file is treated as a file download by the browser. After a page refresh, clicking the URL file will correctly navigate to the URL within the file (desired behaviour).
The same can be seen for a 'txt' file. It is passed off to be rendered by the browser (e.g. displayed in a new tab). After a page refresh, clicking the 'txt' file results in it opening within the SharePoint Text viewer/editor.
Steps to reproduce
- Add an Office document to a library
- Call the Graph API to rename the file to a different format i.e. {Filename}.url
- Call the Graph API to replace the file contents i.e. the .url content
- Wait for the Document Library to reload automatically
- Click the file and observe the rendering is handled by the browser
- Refresh the page and click the file
- Observe the rendering is handled by SharePoint (desired) e.g. the URL shortcut is followed, or the txt file opens within the editor dialog.
Expected behavior
Ideally the behaviour would be consistent, and handled by SharePoint rendering.