1

When I execute the fallowing URL in Internet Explorer

http://sms.horisen.info:12000/bulk/send?type=text&user=xxx&password=xxx&sender=Bulk+Test&receiver=%2b123456789&dcs=UCS&text=Dies+ist+ein+Test!&dlr-mask=19

I get there the message

ERR 103 
No account with given username/password

How can I do this with C#? I have tried:

var url = "http://sms.horisen.info:12000/bulk/send?type=text&user=xxx&password=xxx&sender=Bulk+Test&receiver=%2b123456789&dcs=UCS&text=Dies+ist+ein+Test!&dlr-mask=19";
var req = (HttpWebRequest)WebRequest.Create(url);
var res = req.GetResponse();

But on the last line, there occures a System.Net.WebException How does I have to execute this where I can get the result as text?

BennoDual
  • 5,865
  • 15
  • 67
  • 153

2 Answers2

1

I tried your URL in a C# program and it also gives me an error. This is due to the status code being 420 which makes the .net framework treat the response as an error response and throw an exception. For more info on using responses with error status code have a look here: .Net HttpWebRequest.GetResponse() raises exception when http status code 400 (bad request) is returned

Community
  • 1
  • 1
mortb
  • 9,361
  • 3
  • 26
  • 44
0

This:

var res = req.GetResponse();

Should be this:

var res = (HttpWebResponse)req.GetResponse();

Any particular reason you're using var's?

dtsg
  • 4,408
  • 4
  • 30
  • 40
  • This gives me the same exception. I think it is also the same call. I always using var's ;-) – BennoDual Jul 02 '12 at 12:29
  • Just tested it and those three lines run fine. Perhaps the problem is with the URL you're passing in. What is it you're trying to do anyway? – dtsg Jul 02 '12 at 12:35