New Member
June 25, 2020
Hi,
I am user of Excel Office 365 and trying to fetch data from web (https://www.nseindia.com/marke.....ity-market) into Excel but getting an error message as below:
DataFormat.Error: We found extra characters at the end of JSON input.
Details:
Value=
Position=0
Details in Advanced Query Editor:
let
cookiestr = "A59DDA7465F61E5B5D6572B0BC35ED8A~Z8KhB7i06Ldraa+wZi4WKHL38yNyo2/U/DP8Vi/LZwpWltUEK3I3PVk0gQCu50XthqIMb9J1XyEVRdByJgR2A3/vmKw0AbYwMvaUARaR9eQVopbGYQQaLputuVdZGQaZAebPIdCNO7mLuWiVf8t1qBDy8MglhWdUxZfNYMNFF18=",
Source = Json.Document(Web.Contents("https://www.nseindia.com/market-data/live-equity-market",
[Headers = [#"accept-language"="en-US,en;q=0.9,ta;q=0.8,te;q=0.7", #"accept-encoding"="gzip, deflate", #"user-agent" = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/83.0.4103.106 Safari/537.36",
cookie = "cookiestr"]]))
in Source
Note: Cookie string value may need to be updated when you fetch the data in your machine.
Can anyone let me know what is the issue and how to rectify.
October 5, 2010
Hi Praveen,
The URL in your query responds with HTML not JSON so I get the error in PQ
DataSource.Error: The downloaded data is HTML, which isn't the expected type. The URL may be wrong or you might not have provided the right credentials to the server.
Please supply a file/query/URL that returns JSON.
If you have the URL that responds with JSON, you can enter this into your browser to see the data sent back. You can then check that is valid JSON by using a site like https://jsonformatter.curiousc.....ncept.com/
Regards
Phil
Answers Post
New Member
June 25, 2020
Hi Phil,
Thank you for quick response and I missed to check if it is json or html (still learning).
As I am trying to connect to the URL: https://www.nseindia.com/marke.....ity-market from Excel Get Data from Web option, its throwing an error stating "Unable to Connect - We encountered an error while trying to connect. Details: "The underlying connection was closed. An unexpected error occurred on a receive" (Attached snapshots for reference)
Note: URL does not require any credentials as it is public accessible data.
Regards,
Praveen
October 5, 2010
Hi Praveen,
Looking at the website in my browser, I can see that it periodically sends new information to the browser. I suspect what is happening is that Power Query sits waiting for these updates to finish before loading, but the updates are continuous - so Power Query times out.
You can use Web.BrowserContents to load the web page and force PQ to load the page after a set amount of time. In this example I've set it to 10 seconds.
let
Source = Web.Page( Web.BrowserContents("https://www.nseindia.com/market-data/live-equity-market", [WaitFor = [Timeout = #duration(0,0,0,10)]]))
in
Source
You'll need to use Power BI Desktop to load this query, unless your Excel Power Query supports Web.BrowserContents - mine does not at this point in time. Excel PQ is not updated as regularly as PBI Desktop, even though Web.BrowserContents has been around for at least 5 months.
Regards
Phil
1 Guest(s)