0

I'm trying to get a csv file from the following uri using C# WebClient.

var copUri ="http://obieebr.banrep.gov.co/analytics/saw.dll?Go&Path=%2fshared%2fSeries%20Estad%c3%adsticas_T%2f1.%20IBR%2f1.1.IBR_CSV_XML_ultimos_datos&download_type=csv&NQUser=publico&NQPassword=publico"
var client = new WebClient();
var content = client.DownloadString(copUri);

When I try it in my browser I get the csv file, but the above code is returning the authentication html file instead. How do I get past this html response to get the csv file?

  • Did you try with WebClient.DownloadFile() method instead? – Redouane Jul 28 '17 at 18:49
  • 1
    Looks like on initial hit, it sets some cookies. You'll need to use a cookie-aware client, visit the URI, then visit the same URI again. Only on the second time, will it give you the CSV. – Kyle Jul 28 '17 at 18:51
  • You are downloading the report from the Oracle BI which is very heavy session aware and like @Kyle pointed out sets some session cookies such as `ORA_BIPS_LBINFO` and `ORA_BIPS_NQID` on the very first request. I am not familiar with Oracle BI, but perhaps you can ask this question in https://stackoverflow.com/questions/tagged/obiee. – Eugene Komisarenko Jul 28 '17 at 19:32
  • Tried to use the following cookie-aware webclient (https://stackoverflow.com/questions/2825377/how-can-i-get-the-webclient-to-use-cookies), but the problem still remains.. – Lshenrik Jul 28 '17 at 19:33

2 Answers2

0

You have pass Authorization credentials with uri.

Server rejected your request due to un-authenticate activity.

KUNAL NAYI
  • 35
  • 1
  • 8
  • The "...&NQUser=publico&NQPassword=publico" part in the URI would not enough to pass authentication? – Lshenrik Jul 28 '17 at 20:08
  • They ave applied token base authentication you should required token for authorization. Please try first in postman, ARC or any other client application. – KUNAL NAYI Jul 28 '17 at 20:12
0

The problem was beyond the cookie awareness - the csv was compiled with javascript in the browser. Solved by using Casperjs to render the obfuscating javascript and then getting the data from the underlying instance.