Reputation: 1
I have a Huawei b525-23a router. Using it's web interface you can send/check SMS but I want to do it automatically from an C# app. I didn't found any API documentation for it so any link will be very good. I managed to find some HTTPRequests using Chrome but when I use it from C# I get the 125003 error that is according to some google search an authentication problem.
Here are some parts of my code :
private void button4_Click(object sender, EventArgs e)
{
// getting SenInfo and TokInfo
string urlTokenInfo = "http://192.168.8.1/api/webserver/SesTokInfo";
HttpWebRequest requestTokenInfo = (HttpWebRequest)WebRequest.Create(urlTokenInfo);
requestTokenInfo.Method = "GET";
WebResponse responseTokenInfo = requestTokenInfo.GetResponse();
Stream responseTokenInfoStream = responseTokenInfo.GetResponseStream();
string responseTokenInfoString = new StreamReader(responseTokenInfoStream).ReadToEnd();
var rootElement = XElement.Parse(responseTokenInfoString);
string sessionId = rootElement.Element("SesInfo").Value;
string tokenInfo = rootElement.Element("TokInfo").Value;
//_________________________________________________________________________________
// trying to log
String urlLogin = "http://192.168.8.1/api/user/login";
HttpWebRequest requestLogin = (HttpWebRequest)WebRequest.Create(urlLogin);
requestLogin.Method = "POST";
String XMLLogin;
String base64Passwd = Base64Encode(passwd); //function for base64 encode
XMLLogin = " <request ><Username> " + userName + " </Username><Password> " + base64Passwd + " </Password></request> ";
byte[] requestInFormOfBytes = System.Text.Encoding.ASCII.GetBytes(XMLLogin);
requestLogin.ContentType = "text/xml;charset=utf-8";
requestLogin.ContentLength = requestInFormOfBytes.Length;
Stream requestStream = requestLogin.GetRequestStream();
requestStream.Write(requestInFormOfBytes, 0, requestInFormOfBytes.Length);
requestLogin.Headers.Add("__RequestVerificationToken", tokenInfo);
requestLogin.Headers.Add("Cookie", sessionId);
WebResponse raspuns = (HttpWebResponse)requestLogin.GetResponse();
Stream responseStreamLogin = raspuns.GetResponseStream();
string responseStrlogin = new StreamReader(responseStreamLogin).ReadToEnd();
}
}
The response that I get is
<?xml version="1.0" encoding="UTF-8"?><error><message></message><code>125003</code></error>
Thank you for your time reading this and any response will be apreciated.
Mihai Stanciu
Upvotes: 0
Views: 1009
Reputation: 34037
125003 error means token verification failed.
Check the session and token values in the first html resource request file
Upvotes: 1