Madhu Nali
Madhu Nali

Reputation: 173

Server returned HTTP response code: 500 when we are sending Arabic language content

We are sending HTTPURLRequest to server.

When we are sending English content its working fine.But, when we are sending Arabic language content we are getting

Server returned HTTP response code: 500 

We had written below code

connection = (HttpURLConnection) url.openConnection();          

connection.setRequestMethod("POST");            
connection.setRequestProperty("Content-Type", "text/xml; charset=utf-8");          
connection.setRequestProperty("Content-Length", "" + Integer.toString(SendRequest.getBytes().length));
connection.setUseCaches(false);
connection.setDoInput(true);
connection.setDoOutput(true);            
DataOutputStream dataout = new DataOutputStream(connection.getOutputStream());  
dataout.writeBytes(SendRequest);
dataout.flush();
dataout.close();
BufferedReader bufferreader = new BufferedReader(new InputStreamReader(connection.getInputStream(), "utf-8"));

When I use connection.getInputStream() I am getting 500 error We are using utf-8 also.But, still getting the error can any one help me

Upvotes: 0

Views: 362

Answers (2)

Ele
Ele

Reputation: 33726

You can use a library to escape the special chars:

StringEscapeUtils.escapeJava("هولاء كومو")

This class is available on: Commons Lang from Apache

Hope this helps!

Upvotes: 1

Brandon Heck
Brandon Heck

Reputation: 81

Check the HTTP Status Response Codes. An error happened on the server, so the diagnostics will need to be performed on the server, not on the client.

Upvotes: 0

Related Questions