APIv1 Error : No data in payload. My asp.net service doesn\'t work few days
support
posted this on August 20, 2009 13:43
APIv1 Error : No data in payload. My asp.net service doesn\'t work few days
Comments
support
Handset Detection
Hi,
I create application that use HSD webservice about month ago. But now it doesn\'t work...
Anyone know how can I fix it?
I have responce:
APIv1 Error : No data in payload206
My C# code:
....
string xml = \"\" + ApiKey + \"\" +
\"product_info\" + userAgent + \"\";
string url = \"http://handsetdetection.com/devices/detect.xml\";
XMLRequestHelper xmlrequest = new XMLRequestHelper();
xmlrequest.Send(url, xml);
....
public class XMLRequestHelper
{
// Methods
public void Send(string url, string sXml)
{
HttpWebRequest myHttpWebRequest = (HttpWebRequest)WebRequest.Create(url);
myHttpWebRequest.Method = \"POST\";
byte[] postBytes = Encoding.ASCII.GetBytes(sXml);
myHttpWebRequest.ContentType = \"application/xml\";
myHttpWebRequest.ContentLength = postBytes.Length;
Stream requestStream = myHttpWebRequest.GetRequestStream();
requestStream.Write(postBytes, 0, postBytes.Length);
requestStream.Close();
try
{
HttpWebResponse myHttpWebResponse = (HttpWebResponse)myHttpWebRequest.GetResponse();
StreamReader sr = new StreamReader((myHttpWebResponse.GetResponseStream()));
ResponceText = sr.ReadToEnd();
myHttpWebResponse.Close();
this.StatusCode = myHttpWebResponse.StatusCode;
this.StatusDescription = myHttpWebResponse.StatusDescription;
}
catch (WebException ex)
{
HttpWebResponse response = (HttpWebResponse)ex.Response;
this.StatusCode = response.StatusCode;
this.StatusDescription = response.StatusDescription;
}
}
// Properties
public HttpStatusCode StatusCode { get; private set; }
public string StatusDescription { get; private set; }
public string ResponceText { get; private set; }
}
August 20, 2009 13:43
support
Handset Detection
Hi Methos,
Can you add a header into your request for me ?
I need something to track your requests with. If you can add
myHttpWebRequest.Hdtest = \\\"methos\\\";
then i\'ll be able to track form this end.
Thanks.
Cheers
r
August 20, 2009 14:54
support
Handset Detection
I can send request:
string xml = \"\" + ApiKey + \"\" +
\"product_info\" + userAgent + \"\"+
\"methos\"+
\"\";
It will help you resolve problem?
August 20, 2009 15:56
support
Handset Detection
I create few request with different user-agents
August 20, 2009 16:10
support
Handset Detection
Hi Methos,
For some reason the payload is being dropped before it hits handsetdetection.com
I see a squid proxy between your servers and our servers - I wonder if that has something to do with it ?
Lets try this - Can you change the ContentType to \'text/xml\' ?
Thanks.
Cheers
Richard
August 20, 2009 17:26
support
Handset Detection
Yes, I use ContentType \'text/xml\' and retest it now...
I don\'t understand... Did you recieve my requests? Like:
*****product_infoNokia6600/1.0 (4.09.1) SymbianOS/7.0s Series60/2.0 Profile/MIDP-2.0 Configuration/CLDC-1.0methos
But data in same xml request is lost?
Can you show me my request that you recive?
August 20, 2009 18:15
support
Handset Detection
About proxy server...
We test it in different networks.
I think proxy server doesn\'t change plain text data (xml post).
Does your service recieve valid xml file without some fields?
August 20, 2009 18:22
support
Handset Detection
Hi Methos,
No - i dont see your requests at all - somewhere the whole \"*****product_infoNokia6600/1.0 (4.09.1) SymbianOS/7.0s Series60/2.0 Profile/MIDP-2.0 Configuration/CLDC-1.0methos\" is being dropped.
That would usually happen if for some reason a get was being done instead of a post but your code looks fine.
Can you move the hdtest into the http headers ?
Does C# let you set your own headers on the http request ?
(Like myHttpWebRequest.Hdtest = \"methos\";)
Whats the URL of your website that does the detection ? (so i can test from this end).
Cheers
Richard
August 20, 2009 18:30
support
Handset Detection
Hi Richard,
I create test page on another web site:
http://.../TestDetection.aspx
You can create request to your service with different params. Hope that helps you and me.
Thanks
August 20, 2009 20:22
support
Handset Detection
In my statistics the last request has been processed in july...
August 21, 2009 18:35
support
Handset Detection
Hi Methos,
I dont know what happening here but something isnt right between our servers.
Looking at the headers, if i send a request from your test page i get :
Test request :
Array ( [host] => www.handsetdetection.com [cache-control] => max-age=259200 [content-type] => text/xml [hdtest] => methos [via] => 1.1 siberscity.key-soft.local:3128 (squid/2.6.STABLE5) [x-forwarded-for] => xx.xx.xx.xx [connection] => keep-alive )
vs
Normal Request :
Array ( [host] => c1.handsetdetection.com [content-type] => text/xml [user-agent] => Jakarta Commons-HttpClient/3.1 [x-forwarded-for] => xx.xx.xx.xx [content-length] => 669 [connection] => keep-alive )
So some headers are in there (text/xml) and some arent (content-length). Now this is the weird thing - if i manually set the content-length from the test page then i get a content-length in the headers (but no data).
Can you try it without the proxy ?
Cheers
r
August 22, 2009 11:48
support
Handset Detection
Hi Richard,
I use 2 different public web servers from different countries.
I think proxy server cann\'t change request...
And it has beed worked in July...
August 24, 2009 19:16
support
Handset Detection
Hi Methos,
I can see it was working before, you have requests there.
Nothing has changed on your end & nothing has changed on our end .. yet it stopped working.
Your code looks fine but handsetdetection doesnt see anything in the POST data packet.
This can happen if the content-type isnt set properly because we use HTTP_RAW_POST_DATA to extract the content of a post request but I can see you setting a content type.
I see you setting a content length in the code, but i dont see a content length at this end in the request headers. (This might be the problem).
I have an idea :
We have a project on google code that implements version 2 of our API.
http://code.google.com/p/handset-detection-asp-net-api-kit/http://handset-detection-asp-net-api-kit.googlecode.com/files/hdapi...
The samples are setup to run out of the box with the demo account.
If you download that and give the samples a try. (detect.aspx)
You can login with username demo@handsetdetection.com and password demo to verify the result.
Cheers
Richard
August 24, 2009 20:58
support
Handset Detection
Hi Methos,
Recent developemt : The connection may be related to an issue just discovered with the amazon load balancers. We\'ve made a change at this end. Can you try again ?
If that fails - can you try hitting a server directly ?
http://72.44.33.202 or http://67.202.46.178
Thanks.
Cheers
r
September 01, 2009 01:07
support
Handset Detection
Hmmm. I\'m getting the exact same error (using legacy API). Have been for a while now. When I ping the above IPs it sends the packets of data, but doesn\'t receive the response packets. So, I used the sample aspx API and it worked like a charm. However, how can i get my own parameters for the below code (eg a v2 api key) to populate the code with so I can track my personal stats? Thanks:
HDBase hd = new HDBase(\"demo@handsetdetection.com\", \"demo\");
hd.setv2ApiKey(\"51ce43021c8109c7f7054e709b0f7514\");
hd.setURL(\"http://api-us1.handsetdetection.com\");
January 29, 2010 07:03
support
Handset Detection
....and i\'m not going via a proxy either:
Dim req As System.Net.WebRequest = System.Net.WebRequest.Create(url)
req.Method = \"Post\"
req.ContentType = \"text/xml\"
\'Send Request
\'The encoding might have to be chaged based on requirement
Dim encoder As new System.Text.UTF8Encoding()
Dim data As Byte() = encoder.GetBytes(xml)
req.ContentLength = data.Length
Dim reqStream As System.IO.Stream
reqStream = req.GetRequestStream()
reqStream.Write(data, 0, data.Length)
reqStream.Close()
\'Get response
Dim res As System.Net.WebResponse
res = req.GetResponse()
Dim reader As System.IO.StreamReader
reader = new System.IO.StreamReader(res.GetResponseStream())
Dim str As String
str = reader.ReadToEnd()
Comments