Ask Your Question

C# login/download data

asked 2017-07-25 12:16:09 -0600

We try to use C# to login and download data, login request is ok. and when we run download request , it show us unauthorized.

Code as following:

client.Credentials = new NetworkCredential("user", "password"); client.DownloadFile("", @"C:\Users\wangch\test.txt");

Above section work fine and get response in file test.txt, but when we continue run following resuest, it shows unauthorized.

client.DownloadFile(",3_0),(L_InputDate=2017-07-25)&Select=L_Type_,L_DisplayId,L_City", @"C:\Users\wangch\test.txt1");

message as following: Unhandled Exception: System.Net.WebException: The remote server returned an error: (401) Unauthorized. at System.Net.WebClient.DownloadFile(Uri address, String fileName) at System.Net.WebClient.DownloadFile(String address, String fileName) at Program.Main() in \rae-edm-s-fs01\user$\wangch\My Documents\Visual Studio 2017\Projects\ConsoleApp2\ConsoleApp2\Program.cs:line 14

edit retag flag offensive close merge delete


What are you using for a client? Also are you making sure the cookies and headers get passed back?

bwolven gravatar imagebwolven ( 2017-07-25 14:11:57 -0600 )edit

this is for download data. login work. But load data no authorized.Can u show me some successful code by using C# download data? it seems format is different from Perl. gravatar ( 2017-07-27 16:23:29 -0600 )edit

Please let me know why one work one not work. gravatar ( 2017-07-28 16:07:47 -0600 )edit

1 Answer

Sort by ยป oldest newest most voted

answered 2017-07-31 14:01:44 -0600

updated 2017-07-31 14:05:42 -0600

When I do it I usually create a C# client app and use the x86 or x64 libRETS library for the RETS connectivity. That is by far the easiest way then it does most of the work for you.

There is also this simple C# project that was started to be able to script POSTOBJECT requests that can be expanded to include search transaction if you would like.

edit flag offensive delete link more


can u send me message about download and setup LibRets on C#? gravatar ( 2017-08-03 16:29:58 -0600 )edit

we use same code work in Perl. But why C# show me unauthorized problem in second website. The first web site is login. It works and response message. we need talk to someone who is familiar server login and data load definition. Thanks, gravatar ( 2017-08-04 17:04:47 -0600 )edit
Login/Signup to Answer

Question Tools

1 follower


Asked: 2017-07-25 12:16:09 -0600

Seen: 619 times

Last updated: Jul 31 '17