Error after submitting JSON data through POST

I'm trying to send data through POST to a web server.

Here is the code I'm using to perform the network call:

HttpClient client = new DefaultHttpClient();
HttpConnectionParams.setConnectionTimeout(client.getParams(), 10000);
HttpPost post = new HttpPost(url);
StringEntity se = new StringEntity(json.toString());
se.setContentEncoding("UTF-8");
se.setContentType("application/json");
post.setEntity(se); 
HttpResponse response = client.execute(post);

I've verified using jsonlint that json.toString() returns a valid JSON.

I'm getting this error message as a response:

11-29 11:03:53.080: I/Storefront(1470): Response = <HTML><HEAD><TITLE>Service Unavailable</TITLE></HEAD><BODY><H1>Service Unavailable - Zero size object</H1>The server is temporarily unable to service your request.  Please try againlater.<P>Reference&#32;&#35;15&#46;163431d0&#46;1322593433&#46;2b040d2c</BODY></HTML>

The "Zero size object" message makes me think that the JSON data is not being sent properly.

Answers


Because you are receiving a valid response, it is probably an issue with how you are using the server. Make sure you are using the correct URL and sending the data in the expected manner.


Need Your Help

Pulling in tweets to a tableview in Corona SDk

twitter lua tableview corona

I'm interested in building a tableview to pull in tweets from a twitter profile. Using, Corona SDK, the only twitter option I have found so far is a webview but we would like to display the tweets ...

ASP.NET MVC Routes: How do I omit “index” from a URL

asp.net asp.net-mvc-5 asp.net-mvc-routing

I have a controller called "StuffController" with a parameterless Index action. I want this action to be called from a URL in the form mysite.com/stuff

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.