05-31-2012 05:48 AM
I'm trying to call a REST service that receives POST String parameters and I did it succesfully with URLEncodedPostData until I needed to send a "long" String param (around 40K. It is a single HTML page). Then, I received a 500 error code from the server. Should I consider an special case after a certain size or could it be a server error?
This is how I build the object URLEncodedPostData
URLEncodedPostData data = new URLEncodedPostData("UTF-8", false); data.append("email", user.getEmail()); data.append("password", user.getPassword()); data.append("subject", subject); data.append("content", content);
... then to send the POST
ConnectionFactory conn = new ConnectionFactory(); ConnectionDescriptor desc = conn.getConnection(url); c = (HttpConnection) desc.getConnection(); c.setRequestMethod(HttpConnection.POST); c.setRequestProperty(HttpHeaders.HEADER_CONTENT_TY
PE,data.getContentType()); c.setRequestProperty(HttpHeaders.HEADER_CONTENT_LE NGTH,String.valueOf(data.getBytes().length)); c.setRequestProperty(HttpHeaders.HEADER_ACCEPT, HttpHeaders.CONTENT_TYPE_APPLICATION_XML); OutputStream os = c.openOutputStream(); os.write(data.getBytes()); os.flush(); os.close(); int rc = c.getResponseCode();
So rc is 500 which is bad but if I chop to content to
it works fine. That's why I believe it a problem with the POST size.
Solved! Go to Solution.
05-31-2012 05:55 AM
05-31-2012 06:10 AM
05-31-2012 06:15 AM
The first thing you need to do is confirm that in fact the data hit your server. The 500 response could, especially if the communication was via wireless, be supplied by an intervening gateway. Don't think it is likely, but I think you should check. If you check the headers returned on with the 500 response you should see the Server identified and may be able to determine from that it was in fact your server.
Regarding removing a duplicate post, press the "Report Inappropriate Content" link to the left of the post, and explain your error. That seems to work for me when I do it.....
05-31-2012 07:59 AM