I tried a lot of things to send an SMS with my Huawei E8372, and nothings works.
here is my last code :
var SMS = $"<?xml version='1.0' encoding='UTF-8'?><request><Index>-1</Index><Phones><Phone>0033*********</Phone></Phones><Sca></Sca><Content>byserver</Content><Length>8</Length><Reserved>1</Reserved><Date>{date.ToString("yyyy-MM-dd HH:mm:ss")}</Date></request>";
//var SMS = $"<request><Index>-1</Index><Phones><Phone>003364*******</Phone></Phones><Sca></Sca><Content>by server</Content><Length>9</Length><Reserved>1</Reserved><Date>{date.ToString("yyyy-MM-dd HH:mm:ss")}</Date></request>";
var baseAddress = new Uri("http://192.168.8.1");
using (var handler = new HttpClientHandler { UseCookies = false })
{
using (var client = new HttpClient(handler) { BaseAddress = baseAddress })
{
var message = new HttpRequestMessage(HttpMethod.Post, "/api/sms/send-sms");
//message.Content = new FormUrlEncodedContent(paramse);
message.Content = new StringContent(SMS);
message.Headers.Add("__RequestVerificationToken", token);
message.Headers.Add("Accept", "*/*");
message.Headers.Add("Accept-Encoding", "gzip, deflate");
//message.Headers.Add("Accept-Language", "fr,fr-FR;q=0.8,en-US;q=0.5,en;q=0.3");
message.Headers.Add("Connection", "keep-alive");
//message.Headers.TryAddWithoutValidation("Content-Length", SMS.Length.ToString());
//message.Headers.TryAddWithoutValidation("Content-Type", "application/x-www-form-urlencoded; charset=UTF-8");
message.Headers.Add("Cookie", sessionID);
//message.Headers.Add("Host","192.168.12.116");
//message.Headers.Add("Referer", "http://192.168.12.116:61640/Service1.svc/TryThis");
message.Headers.Add("User-Agent", ".NET Framework Test Client");
//message.Headers.Add("X-Requested-With", "XMLHttpRequest");
}
}
I always have 200 in response code. But I never receive my message. I try to change the header a lot of times, to change the body a lot of times too. And I know the modem works, because I can send sms when I use the Interface in my browser. And I send a request like this interfaces does. But that don't work for my application.
Maybe is because of a security I don't know or something like that. But I'm blocked since 6 days on this problem and I'm totally desperate.
If one of you have a solution or a clue, I will be very grateful.
Thank you in advance.
P.S : I know HttpClient
in an using
is not correct. But this is the only one request my application have to do.
EDIT :
this is the request who send my browser (with this one that work):
header :
Host: 192.168.8.1
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:64.0) Gecko/20100101 Firefox/64.0
Accept: */*
Accept-Language: fr,fr-FR;q=0.8,en-US;q=0.5,en;q=0.3
Accept-Encoding: gzip, deflate
Referer: http://192.168.8.1/html/smsinbox.html?smssent
Content-Type: application/x-www-form-urlencoded; charset=UTF-8
__RequestVerificationToken: 1W7DEw3V5rnPxeg01xqF13kgaPRRtO2d
X-Requested-With: XMLHttpRequest
Content-Length: 234
Connection: keep-alive
Cookie: SessionID=1ALPnbTT+SRZMWfPCfVruPnbm0tC4xHWwiumuySJr9AjTaZYzVK4SGYjNmWOEg7lQDsID+RimQ7HIPa3ZRWipdEXIM9APIP8i+K5JUq2yUAhjpZQuCp+Hx+eCQW5tpm/
body :
<?xml version="1.0" encoding="UTF-8"?><request><Index>-1</Index><Phones><Phone>0033646******</Phone></Phones><Sca></Sca><Content>test browser</Content><Length>12</Length><Reserved>1</Reserved><Date>2018-12-21 07:13:04</Date></request>
So this is really similar to the the request from my Application.