By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
444,119 Members | 2,086 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 444,119 IT Pros & Developers. It's quick & easy.

No Element Found - XML POST

P: n/a
I would like to use the XML API supplied by ClickaTell
(http://www.clickatell.com) in
my code. I have a simple XML file, which I've test in their online demo and
it works
fine. I now want to implement the ability to post the XML by writing some c#
code
to do this.

When I run the code and attempt to do a HTTP post to their URL
(http://api.clickatell.com/xml/xml)
I receive the following error:

"<?xml version="1.0" ?><clickAPI><fault>XML error: no element found at line
1</fault></clickAPI>"

The FAQ on the ClickaTell relates to this error
(http://support.clickatell.com/faq.ph...id=40&kbcat=12)

What I don't understand is the response:

"One of the reasons it may fail is because our XML is not true XML but
rather XML over HTTP. You need
to specify the parameter name for the post as 'data' and only data."
My code is:

================================================== ==================

xmlDOM = new XmlDocument();
xmlDOM.Load("c:/clickaTell.xml");

string strXML = xmlDOM.OuterXml;

Byte[] buf = System.Text.Encoding.UTF8.GetBytes(strXML.ToString ());
objRequest =
(HttpWebRequest)WebRequest.Create("http://api.clickatell.com/xml/xml");

objRequest.Method = "Post";
objRequest.ContentType = "multipart/form-data";

Stream HttpStream;

HttpStream = objRequest.GetRequestStream();
HttpStream.Write(buf, 0, buf.Length);
HttpStream.Close();

objRequest.Timeout = 60000;

objResponse = (HttpWebResponse)objRequest.GetResponse();

Stream receiveStream = objResponse.GetResponseStream();

Encoding UTF8_Encoding = System.Text.Encoding.GetEncoding("utf-8");

StreamReader readStream = new StreamReader(receiveStream, UTF8_Encoding);

char[] read = new char[256];
int count = readStream.Read(read, 0, 256);

while (count > 0)
{
//Write the 256 characters to a string.
String str = new String(read, 0, count);
Response.Write(str);
count = readStream.Read(read, 0, 256);
}
//Close the StreamReader.
readStream.Close();

//Close the HttpWebResponse object.
objResponse.Close();
Response.End();
================================================== ==================
Any Help......please :0(
Nov 11 '05 #1
Share this Question
Share on Google+
1 Reply


P: 1
Hi,

I had the same issue. The XML API isn't clear how to post the data and Clickatell Support are clueless ("We don't offer support to developers....")...

Basically you wrap your XML (without declaration) in a data="<your XML here>"

See an example in PHP here:

http://www.tradersystems.co.uk/ClickatellXMLAPI.html

May not be much use to you but maybe others will find this timely as Google turns this up when I was looking for a solution...

Hope that helps

Jon


I would like to use the XML API supplied by ClickaTell
(http://www.clickatell.com) in
my code. I have a simple XML file, which I've test in their online demo and
it works
fine. I now want to implement the ability to post the XML by writing some c#
code
to do this.

When I run the code and attempt to do a HTTP post to their URL
(http://api.clickatell.com/xml/xml)
I receive the following error:

"<?xml version="1.0" ?><clickAPI><fault>XML error: no element found at line
1</fault></clickAPI>"

The FAQ on the ClickaTell relates to this error
(http://support.clickatell.com/faq.ph...id=40&kbcat=12)

What I don't understand is the response:

"One of the reasons it may fail is because our XML is not true XML but
rather XML over HTTP. You need
to specify the parameter name for the post as 'data' and only data."


My code is:

================================================== ==================

xmlDOM = new XmlDocument();
xmlDOM.Load("c:/clickaTell.xml");

string strXML = xmlDOM.OuterXml;

Byte[] buf = System.Text.Encoding.UTF8.GetBytes(strXML.ToString ());
objRequest =
(HttpWebRequest)WebRequest.Create("http://api.clickatell.com/xml/xml");

objRequest.Method = "Post";
objRequest.ContentType = "multipart/form-data";

Stream HttpStream;

HttpStream = objRequest.GetRequestStream();
HttpStream.Write(buf, 0, buf.Length);
HttpStream.Close();

objRequest.Timeout = 60000;

objResponse = (HttpWebResponse)objRequest.GetResponse();

Stream receiveStream = objResponse.GetResponseStream();

Encoding UTF8_Encoding = System.Text.Encoding.GetEncoding("utf-8");

StreamReader readStream = new StreamReader(receiveStream, UTF8_Encoding);

char[] read = new char[256];
int count = readStream.Read(read, 0, 256);

while (count > 0)
{
//Write the 256 characters to a string.
String str = new String(read, 0, count);
Response.Write(str);
count = readStream.Read(read, 0, 256);
}
//Close the StreamReader.
readStream.Close();

//Close the HttpWebResponse object.
objResponse.Close();
Response.End();
================================================== ==================


Any Help......please :0(
May 14 '06 #2

This discussion thread is closed

Replies have been disabled for this discussion.