500 denotes an Internal Server Error. There is probably no error on your side, it's on the server. Even if you are sending something incorrectly and it's causing the server to return 500, it's still a server problem.
Okey, the server should rather return something like 400 Bad Request instead of 500 Internal Server Error but I found your error now:
DataOutputStream wr = new DataOutputStream (connection.getOutputStream ());
The problem here is that your first get the the bytes from urlParameters using getBytes which (quoting javadoc):
Encodes this String into a sequence of bytes using the platform's default charset
And then you write the bytes using DataOutputStream.writeBytes which (quoting javadoc):
Each character in the string is written out, in sequence, by discarding its high eight bits.
In summary, your Content-Length doesn't match the data. So the server returns you the
java.io.IOException: exceeded content-length limit of 20 bytes
//consider urlParameters.getBytes("UTF-8") method instead of using default encoding
byte bodyData = urlParameters.getBytes();
InputStream out = connection.getOutputStream();
Edit 1 is definitely valid, however, looking over the problem again, I believe the error is definitely caused by the server. I think the server is returning a bad Content-Length header and, when the data is read on Android, the system realizes there is more data coming from the server than it should be by the Content-Length and throws an exception, also replacing the status code by 500 because it really is a server error.
Instead of setting Content-Language which is not neccessary here, you should set Content-Encoding to UTF-8 and instead of empty Accept-Encoding, you should add the real expected MIME-type. I believe this is a server error, but you maybe it won't appear if you set the request headers correctly.
thank you, java.io.IOException: exceeded content-length limit of 20 bytes is there any issue
@test Yes, it's a server issue. Show us server code.
it is working perfectly with ios and i have added server code in my question plz check