Android™
Android™
Xero Delete Account
See more Xero Examples
Deletes an account in a Xero company (Accounting API).Chilkat Android™ Downloads
// Important: Don't forget to include the call to System.loadLibrary
// as shown at the bottom of this code sample.
package com.test;
import android.app.Activity;
import com.chilkatsoft.*;
import android.widget.TextView;
import android.os.Bundle;
public class SimpleActivity extends Activity {
private static final String TAG = "Chilkat";
// Called when the activity is first created.
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
boolean success = false;
// This example requires the Chilkat API to have been previously unlocked.
// See Global Unlock Sample for sample code.
CkHttp http = new CkHttp();
CkJsonObject jsonToken = new CkJsonObject();
success = jsonToken.LoadFile("qa_data/tokens/xero-access-token.json");
if (success == false) {
Log.i(TAG, jsonToken.lastErrorText());
return;
}
http.put_AuthToken(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.put_Accept("application/json");
String url = "https://api.xero.com/api.xro/2.0/Accounts/54ddab14-4a8d-45cf-86be-076c99a0cea0";
CkHttpResponse resp = new CkHttpResponse();
success = http.HttpNoBody("DELETE",url,resp);
if (success == false) {
Log.i(TAG, http.lastErrorText());
return;
}
// A 200 status code indicates success.
Log.i(TAG, "Response Status Code: " + String.valueOf(resp.get_StatusCode()));
Log.i(TAG, "Response Body:");
Log.i(TAG, resp.bodyStr());
}
static {
System.loadLibrary("chilkat");
// Note: If the incorrect library name is passed to System.loadLibrary,
// then you will see the following error message at application startup:
//"The application <your-application-name> has stopped unexpectedly. Please try again."
}
}