http post with blackberry

爱⌒轻易说出口 提交于 2019-11-28 02:13:03

问题


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();

Anyone have any ideas on what could be wrong?


回答1:


A few things were going on. First, my simulator was not connecting to the internet properly. Once that got straightened out, I removed the

deviceside=true

from my url, and it now works great. Thanks all!



来源:https://stackoverflow.com/questions/7500760/http-post-with-blackberry

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!