現在、HttpClient を使用して Android から .net WEB API に接続しています。GET および POST を実行してデータの読み取り/書き込みを行うことができました。ただし、更新と削除を行いたいです。
POST を使用してこれを実行しようとしましたが、簡単にレコードが作成されます。これが POST のコードです。代わりに PUT または DELETE を実行するように変更するにはどうすればよいですか?
HttpClient httpclient = new DefaultHttpClient();
HttpPost httppost = new HttpPost("http://mywebsite.net/api/employees/6");
try {
// Add your data
List<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>(5);
nameValuePairs.add(new BasicNameValuePair("firstName", "UpdatedHello"));
nameValuePairs.add(new BasicNameValuePair("lastName", "World"));
nameValuePairs.add(new BasicNameValuePair("employee_name", "UpdatedHello World"));
nameValuePairs.add(new BasicNameValuePair("password", "xxx"));
nameValuePairs.add(new BasicNameValuePair("isActive", "1"));
httppost.setEntity(new UrlEncodedFormEntity(nameValuePairs));
// Execute HTTP Post Request
HttpResponse response = httpclient.execute(httppost);