I used this code from some url here :
HttpConnection httpConnection = (HttpConnection) Connector.open(webservice_address,Connector.READ_WRITE);
httpConnection.setRequestMethod(HttpConnection.POST);
httpConnection.setRequestProperty("Content-Type", "application/x-www-form-urlencoded");
URLEncodedPostData encPostData = new URLEncodedPostData("UTF-8", false);
encPostData.append("category", String.valueOf(category));
byte[] postData = encPostData.toString().getBytes("UTF-8");
httpConnection.setRequestProperty("Content-Length", String.valueOf(postData.length));
OutputStream os = httpConnection.openOutputStream();
os.write(postData);
os.flush();
os.close();
return httpConnection.getResponseMessage();
But the answer is always the same, I get "null all times" when it is expected that I will have a JSON object response, any idea?
PS: I'm sure the server is sending data
PS: I tried with Connector.READ_WRITE with the same result.
PS: I do it in the Blackberry 9930 simulator
source
share