Solved

HTTP Requests

Posted on 2003-11-14
2
256 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Why don't I see this table in EDMX file? 2 23
Why Does This Page Not Show Up? 4 22
Syntax Error 2 43
Eagerly loading related objects in entity framework 5 24
Article by: Najam
Having new technologies does not mean they will completely replace old components.  Recently I had to create WCF that will be called by VB6 component.  Here I will describe what steps one should follow while doing so, please feel free to post any qu…
This article introduced a TextBox that supports transparent background.   Introduction TextBox is the most widely used control component in GUI design. Most GUI controls do not support transparent background and more or less do not have the…
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: …
This tutorial demonstrates a quick way of adding group price to multiple Magento products.

919 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

18 Experts available now in Live!

Get 1:1 Help Now