Sample code for 30+ languages & platforms
React Native

GetHarvest - Delete Contact

See more GetHarvest Examples

Delete a contact. Returns a 200 OK response code if the call succeeded.

Chilkat React Native Downloads

React Native
import { Http, HttpResponse } from '@chilkat/react-native'

async function chilkatExample() {
  // This example assumes the Chilkat API to have been previously unlocked.
  // See Global Unlock Sample for sample code.

  const 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');

  const resp = new HttpResponse();
  try {
    await http.httpNoBodyAsync('DELETE', 'https://api.harvestapp.com/v2/contacts/CONTACT_ID', resp);
  } catch {
    console.log(http.lastErrorText);
    return;
  }

  const respStatusCode = resp.statusCode;
  console.log(`Response Status Code = ${respStatusCode}`);
  if (respStatusCode !== 200) {
    console.log('Response Header:');
    console.log(resp.header);
    console.log('Response Body:');
    console.log(resp.bodyStr);
    console.log('Failed.');
    return;
  }

  console.log('Success.');
}