Solved

HTTP Requests

Posted on 2003-11-14
2
259 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Salesforce Has Never Been Easier

Improve and reinforce salesforce training & adoption using WalkMe's digital adoption platform. Start saving on costly employee training by creating fast intuitive Walk-Thrus for Salesforce. Claim your Free Account Now

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
VB.NET 2008 Winforms Signing 13 42
IEnumerable<T> to a List<T> 8 54
Upgrade code from VS 2010 to VS 2015 7 34
orderby list (from Json) 1 31
Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
Are you ready to implement Active Directory best practices without reading 300+ pages? You're in luck. In this webinar hosted by Skyport Systems, you gain insight into Microsoft's latest comprehensive guide, with tips on the best and easiest way…

730 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