Register
BlackBerry Unlock
Sponsored By
BlackBerryFAQ
Search
Today's Posts
Mark Forums Read
BlackBerry Forums Support Community
BlackBerry Technical
Developer Forum
Httpconnection Post method problem??
LinkBack
Thread Tools
04-22-2010, 01:49 AM
#
1
(
permalink
)
tramorgan
New Member
Join Date: Apr 2010
Model:
9550
PIN:
N/A
Carrier:
Developer
Posts: 7
Post Thanks: 0
Thanked
0 Times in 0 Posts
Httpconnection Post method problem??
Please Login to Remove!
Hello everyone!
I'm new in BB. I'm trying to work with Httpconnection with Post method.
My problem is the method does not work POST method, it always response 422 error.i dont know what is problem in my code. Please help
Here is my code:
HttpConnection httpConn = null;
String url="link";
InputStream is = null;
OutputStream os = null;
try {
String params="password=123456&username=user";
httpConn = (HttpConnection) Connector.open(url, Connector.READ_WRITE);
httpConn.setRequestMethod(HttpConnection.POST);
httpConn.setRequestProperty("User-Agent",
"Profile/MIDP-2.0 Confirguration/CLDC-1.0");
httpConn.setRequestProperty("Accept_Language", "en-US");
httpConn.setRequestProperty("Content-Type",
"application/x-www-form-urlencoded");
byte[] data=params.getBytes();
httpConn.setRequestProperty("Content-Length", Integer.toString(data.length));
os = httpConn.openOutputStream();
os.write(data);
if (rc != HttpConnection.HTTP_OK) {
throw new IOException("HTTP response code: " + rc);
}
// Read Response from the Server
StringBuffer sb = new StringBuffer();
is = httpConn.openDataInputStream();
int chr;
while ((chr = is.read()) != -1)
sb.append((char) chr);
add(new RichTextField("Source code" + sb.toString()));
}
Last edited by tramorgan : 04-22-2010 at
01:56 AM
.
Offline
04-22-2010, 07:33 AM
#
2
(
permalink
)
Dougsg38p
BlackBerry Extraordinaire
Join Date: Mar 2008
Location: Austin, TX
Model:
9700
PIN:
N/A
Carrier:
T-Mobile
Posts: 1,644
Post Thanks: 0
Thanked
34 Times in 33 Posts
One observation: your User-Agent header has a mispelled word:
Confirguration...
Should be: Configuration
Offline
04-22-2010, 07:23 PM
#
3
(
permalink
)
robleskein
New Member
Join Date: Apr 2010
Model:
8330
PIN:
N/A
Carrier:
AT&T
Posts: 3
Post Thanks: 0
Thanked
0 Times in 0 Posts
That should be it.
HTTP 422 Unprocessable Entity
The request was well-formed but was unable to be followed due to semantic errors.
Offline
04-22-2010, 09:59 PM
#
4
(
permalink
)
tramorgan
New Member
Join Date: Apr 2010
Model:
9550
PIN:
N/A
Carrier:
Developer
Posts: 7
Post Thanks: 0
Thanked
0 Times in 0 Posts
Thanks Dougsg38p and robleskein
Offline
«
Cannot center a GridFieldManager?
|
Custom TextFilter
»
Thread Tools
Show Printable Version
Email this Page
Posting Rules
You
may not
post new threads
You
may not
post replies
You
may not
post attachments
You
may not
edit your posts
vB code
is
On
Smilies
are
On
[IMG]
code is
On
HTML code is
Off
Trackbacks
are
On
Pingbacks
are
On
Refbacks
are
On
Copyright © 2004-2013
BlackBerryFAQ.com
,
BlackBerryForums.com
.
The names
RIM ©
and
BlackBerry ©
are registered Trademarks of
Research In Motion Limited.
Contact Us
-
BlackBerryForums.com
-
Archive
-
Top
LinkBack
LinkBack URL
About LinkBacks
Bookmark & Share
Digg this Thread!
Add Thread to del.icio.us
Bookmark in Technorati
Tweet this thread