Forum Discussion
File on ShP site as a data source
Thank you for your reply. I tried this method, but unfortunately, I got the following error:
Could you please advise?
It looks like you're trying to use the Web.Contents connector to access SharePoint, which is probably why you're getting a 405 error (due to insufficient permissions to access SharePoint via the Web.Contents connector).
As per my previous post, you should be using the SharePoint Folder connector with appropriate authentication. It will generate Source code something like this:
let
Source =
SharePoint.Files(
"https://YourOrgName.sharepoint.com/sites/YourSiteName",
[ApiVersion = 15]
)
in
Source
Pete
- Anonymous3 years agoNot applicable
Last time I used Sharepoint Folder connector. Today I tried differently just with a new query and I still got 405 error:
I am wondering - the link to this SharePoint site looks a bit different as it includes "teams" not "sites". It seems that the file was loaded to ShP via Teams group. Does it make any difference? I'm not a member of this Teams group.
I also tried to use this method for other ShP site, but instead of the content of one of the files loaded there (which is my goal), I just got a list of all files.
Am I doing something wrong?
- BA_Pete3 years agoSuper User
Teams is based on the SharePoint platform, the same as OneDrive for Business, so any Teams site/channel created gets a SharePoint back-end created to provide a platform for it.
Without being able to see your actual SharePoint it's difficult for me to say whether you're using the correct URL or not, but I've not seen a URL from SharePoint contain 'teams' before, I've only seen it contain 'sites' or 'personal/identifier' (for OneDrive).
If you can access the file location on SharePoint you should be able to access the file via Power Query, providing you use the same credentials and apply them at the correct level i.e. at the '~/sites/YourSiteName' level. The 405 error can also be an indication that you don't have permission to access that URL, so make sure you can access the SharePoint destination first. It may also be the case that you need to be given permissions for the Teams site as well, but I don't recall ever needing this myself.
This list of files is just a table, the same as any other, so you can filter it to find the file(s) that you want. Once you've identified the file(s), you can either click the green 'Binary' word in the [Content] column to expand a single file, or hit the two down arrows at the top of that column to combine multiple files.
This is a standard way to connect to SharePoint. It means you only need to authenticate once at the highest level, making the connection highly reusable, and also means that you can select your desired files through logic, making it dynamic too.
As alluded to above, I can't really help a lot more without being able to see your SharePoint/Teams setup or understand your permissions level I'm afraid.
Pete