In my URL i want to replace "{chamber}" with "house"
public class MainActivity extends Activity {
private static String url ="http://10.11.32.199/congressionaldirectory/services/getbillsdetailsbychamber?chamber={chamber}&app_code=125143649";
String jsonStr;
TextView tv;
private static final String TAG_CHAMBER = "chamber";
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
tv=(TextView) findViewById(R.id.textView1);
new GetContacts().execute(url);
}
private class GetContacts extends AsyncTask<String,String,String> {
@Override
protected void onPreExecute() {
super.onPreExecute();
}
@Override
protected String doInBackground(String... params) {
HttpClient httpclient=new DefaultHttpClient();
URI u;
try {
u = new URI(params[0]);
HttpPost HG=new HttpPost(u);
ArrayList<NameValuePair> al=new ArrayList<NameValuePair();
al.add(new BasicNameValuePair(TAG_CHAMBER,"house"));
HG.setEntity(new UrlEncodedFormEntity(al));
HttpResponse response=httpclient.execute(HG);
jsonStr = EntityUtils.toString(response.getEntity());
Log.d("Response: ", "> " + jsonStr);
} catch (URISyntaxException e) {
e.printStackTrace();
}
catch (ClientProtocolException e) {
} catch (IOException e) {
e.printStackTrace();
}
return null;
}
@Override
protected void onPostExecute(String result) {
super.onPostExecute(result);
tv.setText(jsonStr);}}}
if i pass this url directly (http://10.11.32.199/congressionaldirectory/services/getbillsdetailsbychamber?chamber=house&app_code=125143649) its working fine pls help me