When I get a response back I'm always getting the content of a login page (https://datafeeds.networkrail.co.uk/ntrod/spring_security_login) rather than being redirected to the Amazon S3 file.
Just just a side note, I can access the files after visiting that URL manually and typing in my credentials.
I guess my questions are:
- Can the schedule files be downloaded in this way?
- Is the HTTP authorization header what I need to use in order to achieve this download?
WebRequest webRequest = WebRequest.Create(requestUri);string str = Convert.ToBase64String(Encoding.ASCII.GetBytes(username + ":" + password);webRequest.Headers[HttpRequestHeader.Authorization] = "Basic " + str;byte[] buffer = new byte[4096];using (WebResponse response = webRequest.GetResponse()){using (Stream responseStream = response.GetResponseStream()){using (MemoryStream memoryStream = new MemoryStream()){int count;int counter = 0;do{Console.WriteLine("Downloading bytes {0}", counter * 4096);count = responseStream.Read(buffer, 0, buffer.Length);memoryStream.Write(buffer, 0, count);counter++;}while (count != 0);byte[] bytes = memoryStream.ToArray();System.IO.File.WriteAllBytes(filePath, bytes);}}}requestUri would be https://datafeeds.networkrail.co.uk/ntrod/CifFileAuthenticate?type=CIF_HE_TOC_FULL_DAILY&day=toc-full, and filePath would be the local path to save to. You then need to de-compress the file
--
You received this message because you are subscribed to the Google Groups "A gathering place for the Open Rail Data community" group.
To unsubscribe from this group and stop receiving emails from it, send an email to openraildata-t...@googlegroups.com.
To post to this group, send an email to openrail...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
request.Credentials = new NetworkCredential("username", "password");
I am too struggling with this but do not have the c# option available to me so trying the wget with basic authentication route.
wget --user=<username> --password=<password> -O file.gz https://datafeeds.networkrail.co.uk/ntrod/CifFileAuthenticate?type=CIF_ALL_FULL_DAILY&day=toc-fullMostly this reports:
Resolving datafeeds.networkrail.co.uk... 79.125.104.87Connecting to datafeeds.networkrail.co.uk|79.125.104.87|:443... connected.HTTP request sent, awaiting response... 503 Service Unavailable: Back-end server is at capacity17:59:24 ERROR 503: Service Unavailable: Back-end server is at capacity.