Welcome!

Welcome to the Official BlackBerry Support Community Forums. This is your resource to discuss support topics with your peers, and learn from each other. New to the forum? Please visit the ‘Getting Started’ link below.
inside custom component

Java Development

Reply
Regular Contributor
heather_1
Posts: 83
Registered: ‎05-24-2011
My Carrier: XXX
Accepted Solution

http post not working

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?

Please use plain text.
Regular Contributor
heather_1
Posts: 83
Registered: ‎05-24-2011
My Carrier: XXX

Re: http post not working

Solved it. Had to remove deviceside=true

Please use plain text.
Developer
MFSI
Posts: 76
Registered: ‎09-03-2012
My Carrier: Vodafone

Re: http post not working

[ Edited ]

Hi

 

Was your solution also worked for simulator ? I am stuck at same problem but its not runing in simulator at my end.

 

 

Always Success
Please use plain text.