'Authentication error using Yahoo Finance in Power BI when updating data
When trying to autoupdate stock values using Yahoo Finance link from a csv file using this:
Source = Csv.Document(
Web.Contents(
"https://query1.finance.yahoo.com/v7/finance/download/"
& Comp
& "?period1=1022112000&period2="
& LastDate
& "&interval=1d&events=history"
),
[Delimiter = ",", Columns = 7, Encoding = 1252, QuoteStyle = QuoteStyle.None]
Extra info: Comp and lastdate are custom parameters, in which comp fetches all company stock data and lastdate records the most recent stock date.
I keep getting authentication errors everytime I try to access the data using either anonymous or user login. What can I do?
Thanks
Solution 1:[1]
Please check what value you provide to the URL string. Probably there is some error.
You can check this example with function:
let
Source = (STOCKNAME, StartDat, EndDat) => let
Source = Csv.Document(Web.Contents("https://query1.finance.yahoo.com/v7/finance/download/"&STOCKNAME&"?period1="&StartDat&"&period2="&EndDat&"&interval=1d&events=history&includeAdjustedClose=true"),[Delimiter=",", Columns=7, Encoding=1252, QuoteStyle=QuoteStyle.None]),
#"Promoted Headers" = Table.PromoteHeaders(Source, [PromoteAllScalars=true]),
#"Changed Type" = Table.TransformColumnTypes(#"Promoted Headers",{{"Date", type date}, {"Open", type text}, {"High", type text}, {"Low", type text}, {"Close", type text}, {"Adj Close", type text}, {"Volume", Int64.Type}})
in
#"Changed Type"
in
Source
Query:
let
Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WCgkPCVLSUTI0M7E0MzY1MjCAcsyNDM2AnFidaCVPvxBnVFEIx8LAwgCkJBYA", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [TICKER = _t, Start = _t, End = _t]),
#"Changed Type" = Table.TransformColumnTypes(Source,{{"TICKER", type text}}),
#"Invoked Custom Function" = Table.AddColumn(#"Changed Type", "GetStock", each GetStock([TICKER], [Start], [End])),
#"Expanded GetStock" = Table.ExpandTableColumn(#"Invoked Custom Function", "GetStock", {"Date", "Open", "High", "Low", "Close", "Adj Close", "Volume"}, {"GetStock.Date", "GetStock.Open", "GetStock.High", "GetStock.Low", "GetStock.Close", "GetStock.Adj Close", "GetStock.Volume"})
in
#"Expanded GetStock"
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | msta42a |


