I need to create a httpentiy like this:
"project" => {"name" => "lorem", "description" => "ipsum"}
for my RoR webservice
my code:
private String postData(String url, String user, String password, ArrayList<NameValuePair> nameValuePairs) throws ClientProtocolException, IOException
{
HttpPost httppost = new HttpPost(url);
HttpClient httpclient = this.getDefaultHttpClient(20000, user, password);
httppost.setEntity(new UrlEncodedFormEntity(nameValuePairs));
HttpResponse r = httpclient.execute(httppost);
return inputStreamToString(r.getEntity().getContent());
}
that allows my only to do somthing like this:
"name" => "lorem", "description" => "ipsum"
has anyone a clean solution?
Hope this solves your problem…
List<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>();nameValuePairs.add(new BasicNameValuePair("project[name]", "Dinash"));
nameValuePairs.add(new BasicNameValuePair("project[description]", "dina"));