Hi Satya,
setQueryString() assumes that the content is already URL encoded and it is then sent as part of the request line, i.e.:
POST /path?QUERY_STRING HTTP/1.1
My guess is that you want to send the query string as part of the message body. You can do this with:
mehod.setRequestBody(userModel.getQueryString());
Mike
On Jun 3, 2004, at 7:13 PM, [EMAIL PROTECTED] wrote:
I am using the following code:
HttpClient client = new HttpClient(connMgr);
client.setHostConfiguration(hostConfig);
PostMethod method = new PostMethod(tokenURL);
method.setQueryString( userModel.getQueryString() );
client.executeMethod(method);
byte[] responseBody = method.getResponseBody();
method.releaseConnection();
The response I get is : Request format is invalid: .
--------------
However, If I run the same query using the following code:
con.setRequestMethod("POST");
con.setDoOutput(true);
con.setDoInput(true);
OutputStreamWriter writer = new OutputStreamWriter(con.getOutputStream());
writer.write( userModel.getQueryString() );
writer.flush();
writer.close();
InputStream resultStream = con.getInputStream();
BufferedReader reader = new BufferedReader(new InputStreamReader(resultStream));
StringBuffer aResponse = new StringBuffer();
String aLine = reader.readLine();
while(aLine != null){ aResponse.append(aLine); aLine = reader.readLine(); } resultStream.close(); releaseConnection(con); String retData = aResponse.toString();
I get the expected string as a response. What I am doing wrong in using HttpClient? Any Idea?. -Satya
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]