Java
Chilkat2 Java
GetHarvest - Delete Contact
See more GetHarvest Examples
Delete a contact. Returns a 200 OK response code if the call succeeded.Chilkat Java Downloads
import com.chilkatsoft.chilkat2.ChilkatException;
import com.chilkatsoft.chilkat2.Http;
import com.chilkatsoft.chilkat2.HttpResponse;
public class ChilkatExample {
public static void main(String[] args) {
// This example assumes the Chilkat API to have been previously unlocked.
// See Global Unlock Sample for sample code.
Http http = new Http();
// Implements the following CURL command:
// curl "https://api.harvestapp.com/v2/contacts/CONTACT_ID" \
// -H "Authorization: Bearer ACCESS_TOKEN" \
// -H "Harvest-Account-Id: ACCOUNT_ID" \
// -H "User-Agent: MyApp (yourname@example.com)" \
// -X DELETE
http.setRequestHeader("User-Agent", "MyApp (yourname@example.com)");
http.setRequestHeader("Authorization", "Bearer ACCESS_TOKEN");
http.setRequestHeader("Harvest-Account-Id", "ACCOUNT_ID");
HttpResponse resp = new HttpResponse();
try {
http.httpNoBody("DELETE", "https://api.harvestapp.com/v2/contacts/CONTACT_ID", resp);
} catch (ChilkatException e) {
System.out.println(e.getLastErrorText());
return;
}
int respStatusCode = resp.getStatusCode();
System.out.println("Response Status Code = " + respStatusCode);
if (respStatusCode != 200) {
System.out.println("Response Header:");
System.out.println(resp.getHeader());
System.out.println("Response Body:");
System.out.println(resp.getBodyStr());
System.out.println("Failed.");
return;
}
System.out.println("Success.");
}
}