E
E
estry2017-03-02 13:01:20
RESTful API
estry, 2017-03-02 13:01:20

RestSharp how to set proxy?

Hello. It is not difficult for anyone to show an example of proxy substitution using the restsharp library connected to zennoposter. Thank you!

Answer the question

In order to leave comments, you need to log in

1 answer(s)
E
estry, 2017-03-02
@estry

I asked it myself, I'll answer it myself ;)
string strProxyces = "87.34.132.43:[email protected]:password";
if (strProxyces!=String.Empty){
string[] arrProxy = strProxyces.Split('@');
string strProxyPort = arrProxy[0];
string strLoginPass = arrProxy[1];
string[] arrProxyPort = strProxyPort.Split(':');
string strProxy = arrProxyPort[0];
string strPort = arrProxyPort[1];
string[] arrUserPass = strLoginPass.Split(':');
string strUser = arrUserPass[0];
string strPass = arrUserPass[1];
int strPorts = Convert.ToInt32(strPort);
project.SendInfoToLog("ProxyPort: " + strProxyPort);
project.SendInfoToLog("LoginPass: " + strLoginPass);
project.SendInfoToLog("Proxy: " + strProxy);
project.SendInfoToLog("Port: " + strPorts);
project.SendInfoToLog("Login: " + strUser);
project.SendInfoToLog("Pass: " + strPass);
ApiClient.Proxy = new System.Net.WebProxy(strProxy, strPorts){
UseDefaultCredentials = false,
Credentials = new System.Net.NetworkCredential(strUser, strPass)
};
}

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question