Server error

Valentin

Board Regular
Joined
Oct 29, 2010
Messages
96
Office Version
  1. 365
Platform
  1. Windows
I have been using the following query for some time to download the data from the website "Nationale loterij" (Belgium). Most of the time the query works fine but sometimes I get the message "server error Section = ResponseHeader Detail = CR must by followed with LF". I've already changed the code with "cookies ignore". This has worked for quite some time but for example today it failed once and worked later in the day.

Power Query:
let

Source = Csv.Document(Web.Contents("https://www.nationale-loterij.be/api/drawresults/Elot/drawresultinfo/exportcsv?startDate=2020-12-01T00:00:00.0000000&endDate=2020-12-31T23:59:59.0000000", [Headers=[cookies="ignore"]]),[Delimiter=";", Columns=8, Encoding=1252, QuoteStyle=QuoteStyle.None]),

#"Changed Type" = Table.TransformColumnTypes(Source,{{"Column1", type text}, {"Column2", type text}, {"Column3", type text}, {"Column4", type text}, {"Column5", type text}, {"Column6", type text}, {"Column7", type text}, {"Column8", type text}}),

#"Removed Top Rows" = Table.Skip(#"Changed Type",1),

#"Promoted Headers" = Table.PromoteHeaders(#"Removed Top Rows", [PromoteAllScalars=true]),

#"Changed Type1" = Table.TransformColumnTypes(#"Promoted Headers",{{"Datum", type date}, {"Nummer 1", Int64.Type}, {"Nummer 2", Int64.Type}, {"Nummer 3", Int64.Type}, {"Nummer 4", Int64.Type}, {"Nummer 5", Int64.Type}, {"Ster 1", Int64.Type}, {"Ster 2", Int64.Type}}),

#"Kept First Rows" = Table.FirstN(#"Changed Type1",1)

in

#"Kept First Rows"
 

Excel Facts

What is =ROMAN(40) in Excel?
The Roman numeral for 40 is XL. Bill "MrExcel" Jelen's 40th book was called MrExcel XL.
it works for me
Power Query:
let
    Source = Csv.Document(Web.Contents("https://www.nationale-loterij.be/api/drawresults/Elot/drawresultinfo/exportcsv?startDate=2020-12-01T00:00:00.0000000&endDate=2020-12-31T23:59:59.0000000"),[Delimiter=";", Columns=8, Encoding=1252, QuoteStyle=QuoteStyle.None]),
    Skip = Table.Skip(Source,1),
    Promote = Table.PromoteHeaders(Skip, [PromoteAllScalars=true]),
    Type = Table.TransformColumnTypes(Promote,{{"Datum", type date}, {"Nummer 1", Int64.Type}, {"Nummer 2", Int64.Type}, {"Nummer 3", Int64.Type}, {"Nummer 4", Int64.Type}, {"Nummer 5", Int64.Type}, {"Ster 1", Int64.Type}, {"Ster 2", Int64.Type}}),
    FirstN = Table.FirstN(Type,1)

in
    FirstN
 
Upvote 0
Someone an idea why it sometimes doesn't work?
and what can I do to prevent that, for example with an "On error"
 
Upvote 0
have found other solution, without power query. This has already worked dozens of times without server error
VBA Code:
ShLottoData.QueryTables.Add("URL;https://www.nationale-loterij.be/api/drawresults/Lotto6/drawresultinfo/exportcsv?startDate=2020-12-23T00:00:00.0000000&endDate=2020-12-23T23:59:59.0000000", Destination:=Range("A1")).Refresh True
 
Upvote 0
Solution

Forum statistics

Threads
1,223,750
Messages
6,174,291
Members
452,554
Latest member
Louis1225

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top