Forum Discussion

Emalong94's avatar
Emalong94
Copper Contributor
Jul 10, 2023
Solved

(Solved) Power Query credentials with data from SharePoint

Hi Everyone,

 

I have an Excel file in A SharePoint folder meant as a template for users that can download it to run specific tasks.

To validate the template drop-down lists, the file gets data from another file in the same SharePoint folder which gets refreshed overnight through another integration.

Here's where it gets tricky: if User don't have Edit permission on the whole SharePoint site, they cannot validate their credentials when opening the template and the Query fails to run. 

 

Since I cannot grant Edit permissions on the whole SharePoint site, what can I do to solve the issue?

The query is based on the function Sharepoint.contents:

 

 

 

 

 

 

let
    Source = SharePoint.Contents("https://hanes.sharepoint.com/sites/mysite", [ApiVersion = 15]),
    #"Store timesheets" = Source{[Name="my SP folder"]}[Content],
    Template = #"my SP folder"{[Name="Template"]}[Content],
    #"my data source xlsx" = Template{[Name="my data source.xlsx"]}[Content],
    #"Imported Excel" = Excel.Workbook(#"my data source xlsx"),
    #"Excel Output_Sheet" = #"Imported Excel"{[Item="Excel Output",Kind="Sheet"]}[Data]

 

 

 

 

 

 


I need your help very bad!

Thank you!

 

  • Emalong94 

    You don't need to call entire SharePoint site to filter and access single file. Instead you may use From Web connector. Open file in desktop app, File->copy path at the top. Remove ?web=1 at the end of URL and use it in From Web connector.

     

    With that you may give user R/O rights on Template, that will be enough.

  • Emalong94 

    You don't need to call entire SharePoint site to filter and access single file. Instead you may use From Web connector. Open file in desktop app, File->copy path at the top. Remove ?web=1 at the end of URL and use it in From Web connector.

     

    With that you may give user R/O rights on Template, that will be enough.

    • Emalong94's avatar
      Emalong94
      Copper Contributor
      Hi @Sergei,

      I changed the connector from Sharepoint.contents to Web.contents, it works thank you!

      The log-in pop-up will still open when Users will access the Template file for the first time and it will be challenging explain them how to correctly sign in with organizational account but at least they can run the query.

      About the source file (aka "Datasouce.xlsx"), are you sure they only need R/O rights and not Edit rights instead?

      Thank you,
      Emanuele
      • SergeiBaklan's avatar
        SergeiBaklan
        MVP

        Emalong94 

        Hi Emanuele,

        I'm not 100% sure since didn't test exactly, but from common logic R/O shall be enough to query the file.

Resources