Sp-dev-docs: Docs on usage of Web.GetFileByUrl method in SharePoint REST API?

Created on 17 Sep 2020  ·  5Comments  ·  Source: SharePoint/sp-dev-docs

Hi,

I see that there are docs for using GetFolderByServerRelativeUrl and GetFileByServerRelativeUrl methods in the SharePoint REST API, however, I couldn't find any docs on using GetFileByUrl method with SharePoint REST API.

Could that information be added please?

Thanks,


Document Details

Do not edit this section. It is required for docs.microsoft.com ➟ GitHub issue linking.

csorest docs-comment answered question

All 5 comments

Thank you for reporting this issue. We will be triaging your incoming issue as soon as possible.

Actually, Official document didn't list the usage of GetFileByUrl.
This is the sample to use this method, actually it's using the absolute file url like this:

https://tenant.sharepoint.com/_api/web/GetFileByUrl(@url)?@url='https://tenant.sharepoint.com/Shared%20Documents/0%20(7).jpg'

This is the difference with GetFileByServerRelativeUrl

Thanks @Jerry0527

I've given it a shot and I'm getting either the FileNotFound or "fileURL" is missing error, I've tried different combinations.

What am I doing wrong here, here's my example:
https://contoso.sharepoint.com/_api/web/GetFileByUrl(@url)?@url='https://contoso.sharepoint.com/teams/TechTeam-Contoso-/Shared%20Documents/General/Email%20Messages/FW%20Phase%201%20Migration%20%20to%20affected%20users_123456.eml'

Also, the actual link that I get for the file is:
https://contoso.sharepoint.com/:u:/r/teams/TechTeam-contoso-/Shared%20Documents/General/Email%20Messages/FW%20Phase%201%20Migration%20%20to%20affected%20users_123456.eml?csf=1&web=1&e=abcDEf

Closing this issue as "answered". If you encounter a similar issue(s), please open up a new issue. See our wiki for more details: Issue-List: Our approach to closed issues

Was this page helpful?
0 / 5 - 0 ratings