Forum Discussion

NathanV8's avatar
NathanV8
Frequent Visitor
2 years ago

Data Web API Refresh Issue

Hello All, 
I have a dillemma id like some asisstance with. I have the age old Web.Contents scheduled refresh issue when i build reports from a specific source (I pretty much only work with htis source. 

I have the below M Code for the data 

 

 

let

Source = Csv.Document(Web.Contents("Put Helm CONNECT CSV Connection String Here", [ApiKeyName= "apikey"]),[Delimiter=",", Encoding=65001, QuoteStyle=QuoteStyle.Csv]),#"Promoted Headers" = Table.PromoteHeaders(Source)

in

#"Promoted Headers"

 

 


But witht he above I subsequantly cannot refresh this on the service and the onlyw ay i could figure to make this work is via the below by addine api within the query 

 

 

let
    ApiKey = "your_api_key_here",
    Url = "CSV String here&apikey=" & ApiKey, //keep the &apikey=
    Source = Csv.Document(Web.Contents(Url), [Delimiter=",", Encoding=65001, QuoteStyle=QuoteStyle.Csv]),
    #"Promoted Headers" = Table.PromoteHeaders(Source)
in
    #"Promoted Headers"

 

 

 

But this obviousis not the most secure way pass the API key this way. 

Does anyone have any better solutions i could try to be more secure witht he API key as Im not always the one witht he key so the ideal situation would be to prompt thd user to place the key in when they get the file to upload to there own service and it then allows scheduled refresh


I have done some research on the topic and mosta  referencing the jscontents and some arent working for (inc the Skip test connection)

 

1 Reply

Replies have been turned off for this discussion
  • Anonymous's avatar
    Anonymous
    Not applicable

    Hi NathanV8 

     

    What error did you meet when using the first method with the parameter ApiKeyName in Web.Contents? According to the official document, this method seems to work. Web.Contents - PowerQuery M | Microsoft Learn

     

    Best Regards,
    Jing
    If this post helps, please Accept it as Solution to help other members find it. Appreciate your Kudos!