0

Hello guys I struggle to connect and disconnect modems 3g, I found via Fiddler how POST request looks like but cant make it work via C# under button. Anyone have experience with it? Im sharing data sniffed via Fiddler, wish someone know how to fix it :(

// Connect
POST http://192.168.1.1/api/dialup/dial HTTP/1.1
Host: 192.168.1.1
Connection: keep-alive
Content-Length: 75
Accept: */*
X-Requested-With: XMLHttpRequest
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/89.0.4389.128 Safari/537.36
Content-Type: application/x-www-form-urlencoded
Origin: http://192.168.1.1
Referer: http://192.168.1.1/html/index.html
Accept-Encoding: gzip, deflate
Accept-Language: en-US,en;q=0.9,pl-PL;q=0.8,pl;q=0.7

<?xml version="1.0" encoding="UTF-8"?><request><Action>1</Action></request>

// Disconnect
POST http://192.168.1.1/api/dialup/dial HTTP/1.1
Host: 192.168.1.1
Connection: keep-alive
Content-Length: 75
Accept: */*
X-Requested-With: XMLHttpRequest
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/89.0.4389.128 Safari/537.36
Content-Type: application/x-www-form-urlencoded
Origin: http://192.168.1.1
Referer: http://192.168.1.1/html/index.html
Accept-Encoding: gzip, deflate
Accept-Language: en-US,en;q=0.9,pl-PL;q=0.8,pl;q=0.7


<?xml version="1.0" encoding="UTF-8"?><request><Action>0</Action></request>

1 Answers1

0

Okay I found solution, maybe someone gonna find it as helpful asnwer

using (WebClient client = new WebClient())
            {
                client.Proxy = new WebProxy("192.168.100.19", 3128);


                byte[] request = client.UploadData("http://192.168.1.1/api/dialup/dial", "POST",
                Encoding.ASCII.GetBytes("<?xml version=\"1.0\" encoding=\"UTF - 8\"?><request><Action>1</Action></request>"));

                string final = Encoding.ASCII.GetString(request);
                textBox1.Text = final;

            }