c# - How to enter login/password details and get data -
there 1 website , want data c# application there.
i enter url on web browser http://x.com/api/my_id, firstly messagebox login.

and when enter account response.
{"success":true,"message":null} i want on c#, return response on variable. tried methods httpwebrequest, webclient couldn't (i had errors 405 method not allowed) can me on this? t
thanks comment, dont know how found solution when posted here, sorry. example code solved it.
        webclient client = new webclient();         string username = "id";         string password = "pw";         string url = "http://x.com/api/" + username;          client.credentials =  new system.net.networkcredential(username,password);          string credentials = convert.tobase64string(encoding.ascii.getbytes(username + ":" + password));          client.headers[httprequestheader.authorization] = "basic " + credentials;          var result = client.downloadstring(url);         textbox1.text = result; 
Comments
Post a Comment