Solved

HTTP Requests

Posted on 2003-11-14
2
255 Views
Last Modified: 2010-04-16
Hi,

I need to be able to post some data using and HTTP request to an SMS gateway.  How do I do this in .Net?  I have found the same old sample on 10000s of sites where you can grab and display a web site - but thats not what I need.

An example of the request that needs to be sent:

--------------------------------------------------

POST /SOMESPECIFIEDDIR.sms HTTP/1.1
HOST: the.url.com
CONTENT-LENGTH: CONTENTLENGTH

XmlMsg=ENCODEDDATA

--------------------------------------------------

I'm guessing this is a simple job as its simple enough in PHP.



PS here's that same old sample I keep finding.
------------------------------------------------------
WebRequest smsRequest = HttpWebRequest.Create(uri);
smsRequest.Method = "POST";
                  
WebResponse smsResponse = smsRequest.GetResponse();
StreamReader smsStream = new System.IO.StreamReader(smsResponse.GetResponseStream());
                  
return smsStream.ReadToEnd();
0
Comment
Question by:dpwdc
2 Comments
 
LVL 10

Accepted Solution

by:
ptmcomp earned 80 total points
ID: 9749315
Stream requestStream = smsRequest.GetRequestStream();
StreamWriter requestWriter = new StreamWriter(requestStream, Encoding.UTF8 /* or whatever you need */);
requestWriter.WriteLine("XmlMsg=ENCODEDDATA"); // this is sent as POST data

or if it's in the Header:

smsRequest.Headers.Add("XmlMsg=ENCODEDDATA"); // this is sent in the header
0
 
LVL 1

Author Comment

by:dpwdc
ID: 9949859
close enough.  i worked it out.
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Introduction This article series is supposed to shed some light on the use of IDisposable and objects that inherit from it. In essence, a more apt title for this article would be: using (IDisposable) {}. I’m just not sure how many people would ge…
This article describes a simple method to resize a control at runtime.  It includes ready-to-use source code and a complete sample demonstration application.  We'll also talk about C# Extension Methods. Introduction In one of my applications…
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.

758 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

27 Experts available now in Live!

Get 1:1 Help Now