Java Requires Chilkat v11.0.0+
Chilkat2 Java
Xero Delete Account
See more Xero Examples
Deletes an account in a Xero company (Accounting API).Chilkat Java Downloads
import com.chilkatsoft.chilkat2.ChilkatException;
import com.chilkatsoft.chilkat2.Http;
import com.chilkatsoft.chilkat2.HttpResponse;
import com.chilkatsoft.chilkat2.JsonObject;
public class ChilkatExample {
public static void main(String[] args) {
// This example requires the Chilkat API to have been previously unlocked.
// See Global Unlock Sample for sample code.
Http http = new Http();
JsonObject jsonToken = new JsonObject();
try {
jsonToken.loadFile("qa_data/tokens/xero-access-token.json");
} catch (ChilkatException e) {
System.out.println(e.getLastErrorText());
return;
}
http.setAuthToken(jsonToken.stringOf("access_token"));
// Replace the value here with an actual tenant ID obtained from this example:
// Get Xero Tenant IDs
http.setRequestHeader("Xero-tenant-id", "83299b9e-5747-4a14-a18a-a6c94f824eb7");
http.setAccept("application/json");
String url = "https://api.xero.com/api.xro/2.0/Accounts/54ddab14-4a8d-45cf-86be-076c99a0cea0";
HttpResponse resp = new HttpResponse();
try {
http.httpNoBody("DELETE", url, resp);
} catch (ChilkatException e) {
System.out.println(e.getLastErrorText());
return;
}
// A 200 status code indicates success.
System.out.println("Response Status Code: " + resp.getStatusCode());
System.out.println("Response Body:");
System.out.println(resp.getBodyStr());
}
}