hc-httpclient-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Marcin Kudla <marcin.ku...@googlemail.com>
Subject Re: POST parameters problem
Date Wed, 22 Apr 2009 12:45:12 GMT
Thanks

It's helpful.

Regards
Marcin


2009/4/22 Brijesh Deo <bdeo@sonicwall.com>

> You have to set the post params in the Entity of the request object as
> shown below.
>
> List <NameValuePair> nvps = new ArrayList <NameValuePair>();
>    nvps.add(new BasicNameValuePair("name1", "value1"));
>    nvps.add(new BasicNameValuePair("name2", "value2"));
>    nvps.add(new BasicNameValuePair("name3", "value3"));
> ...and so on.....
>
> Then, set this into the request entity.
>
> request.setEntity(new UrlEncodedFormEntity(nvps, HTTP.UTF_8));
> httpClient.execute(request);
>
>
> //THIS IS NOT REQUIRED
> //request.getParams().setParameter("name", "value");
>
>
> Hope this helps.
>
> Thanks,
> Brijesh
>
>
>
> -----Original Message-----
> From: Marcin Kudla [mailto:marcin.kudla@googlemail.com]
> Sent: Wednesday, April 22, 2009 2:20 PM
> To: httpclient-users@hc.apache.org
> Subject: POST parameters problem
>
> Hello
>
> I want add my custom POST parameter to request.
> I use org.apache.http.client.HttpClient for it and code fragment looks
> like
> :
>
> HttpClient httpClient = new DefaultHttpClient();
> HttpUriRequest request = new new HttpPost("http://some.uri");
> //request.getParams().setParameter("name", "value"); //THIS IS NOT
> REQUIRED
> httpClient.execute(request);
>
> But when it executes custom parameter doesn't send.
> Any suggestion will be highly appreciated.
>
> Regards
> Marcin
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: httpclient-users-unsubscribe@hc.apache.org
> For additional commands, e-mail: httpclient-users-help@hc.apache.org
>
>

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message