3
Reply

web service using web url need help

Mark Tabor

Mark Tabor

Feb 15 2017 4:45 AM
168
I am consuming a web serivce for sending sms below is my code 
private void button1_Click(object sender, RoutedEventArgs e)
{
string key = txtKey.Text;
string secret = txtSecret.Text;
string to = txtTo.Text;
string messages = txtMessage.Text;
string sURL;
StreamReader objReader;
sURL = "https://www.thetexting.com/rest/sms/json/message/send?api_key=" + key + "&api_secret=" + secret + "&to=" + to + "&text=" + messages;
WebRequest wrGETURL;
wrGETURL = WebRequest.Create(sURL);
try
{
Stream objStream;
objStream = wrGETURL.GetResponse().GetResponseStream();
MessageBox.Show("Message Send Successfully", "My Demo App");
objReader = new StreamReader(objStream);
objReader.Close();
}
catch (Exception ex)
{
MessageBox.Show("Something went wrong with your information", "My Demo App");
ex.ToString();
}
}
basically i am creating a url and when this below line executes my message send to the recepient
objStream = wrGETURL.GetResponse().GetResponseStream(); 
 
if i place the wrong credentials and after the execuation of the above line still it saying success message wether it is not sending message , how to check that objStream is successful or not ? i cannot verify the credentails from here , and the web service is just a url to if using input wrong credentials and sms not send how to show message of sms not send . 
 
 

Answers (3)