09-21-2011 09:43 AM
I am trying to set up an http post in my Blackberry app. I have successfully implemented this in my corresponding Android app, so I know the server it working find. I have tried several different things, and I'm not really getting errors, its just the info on the server is not getting updated. I have looked at this post: Http POST in BlackBerry, and several others. I found them helpful, but they didn't ultimately solve my problem. Again, I don't get errors, but the server doesn't get updated. Here is the code I am currently using:
String url = "http://xxxx.com/ratings/add?;deviceside=true"; String postStr1 = "business_id=790"; String postStr2 = "&rating=4"; HttpConnection httpConnection = (HttpConnection) Connector.open(url); httpConnection.setRequestMethod(HttpConnection.POST); httpConnection.setRequestProperty("Content-Type", "application/x-www-form-urlencoded"); URLEncodedPostData encPostData = new URLEncodedPostData("UTF-8", false); encPostData.append("business_id", String.valueOf(790)); encPostData.append("rating", String.valueOf(4)); byte[] postData = encPostData.toString().getBytes("UTF-8"); httpConnection.setRequestProperty("Content-Length" , String.valueOf(postData.length)); OutputStream os = httpConnection.openOutputStream(); os.write(postData); os.flush();
Any ideas?
Solved! Go to Solution.
09-21-2011 11:04 AM
Solved it. Had to remove deviceside=true
10-30-2012 05:15 AM - edited 10-30-2012 05:16 AM
Hi
Was your solution also worked for simulator ? I am stuck at same problem but its not runing in simulator at my end.