PnPContext.Web does not provide GetFileByUrl
See original GitHub issueCategory
- Bug
Describe the bug
It seems like the PnPContext.Web
instance does not provide the method GetFileByUrl
. I need that method because it works flawlessly with different sharepoint links (Share with people who have access link, direct link etc.). I can use this method manually using PnPContext.Site.ExecuteRequestAsync
+ matching ApiRequest
instance like so:
var request = new ApiRequest(ApiRequestType.SPORest, $"_api/web/GetFileByUrl('{my_url}')");
var response = await context.Site.ExecuteRequestAsync(request);
var model = JsonDocument.Parse(response.Response);
Any possibility to parse this model or response at least into a IFile instance? So that I can work normally with the GetContentAsync
function?
Expected behavior
GetFileByUrl
is available through the Web instance property of the PnPContext
Issue Analytics
- State:
- Created 2 years ago
- Comments:12 (5 by maintainers)
Top Results From Across the Web
SPO - Get file by URL (generated by "Get Link")
Recently found the solution by myself (partly using PnP) - function GetFileByUrl does the job. cls $credential = Get-Credential ...
Read more >pnpcore/docs/using-the-sdk/files-intro.md at dev
The PnP Core SDK is a modern .NET SDK designed to work for Microsoft 365. It provides a unified object model for working...
Read more >Get-PnPContext | PnP PowerShell
Retrieve the value for this parameter by either specifying -ReturnConnection on Connect-PnPOnline or by executing Get-PnPConnection. If not provided, the ...
Read more >Working with webs | PnP Core SDK
The PnP Core SDK is a modern .NET SDK designed to work for Microsoft 365. It provides a unified object model for working...
Read more >PnP Core .Net Access subfolder inside my Documents ...
Currently implementing Code to Access a specific Folder called "Customer" which is inside my Documents Folder in Sharepoint. Whatever I tried it ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@jansenbe Seems like I had some error in my previous code. Now it really works. Code which works (but is currently still ugly^^):
Now I just need to take the
@microsoft.graph.downloadUrl
value and remove everything after the _layouts to get the site url. Thank you!Hey @jansenbe,
thank you for the fast response. Yeah I know that this method exist. But
GetFileByUrl
can work with share links without problems.For example this link:
https://tenant.sharepoint.com/:b:/r/sites/hr/Shared%20Documents/contoso_report.pptx
orhttps://tenant.sharepoint.com/:p:/g/EVJ5zTXVJ0pGnTUuYQ3mlYIByIJRTNy1Sbtzme-CZ9D7lQ
So the benefit is that I can just use the share link and then download the document.