C
C
GetHarvest - Delete Contact
See more GetHarvest Examples
Delete a contact. Returns a 200 OK response code if the call succeeded.Chilkat C Downloads
#include <C_CkHttp.h>
#include <C_CkHttpResponse.h>
void ChilkatSample(void)
{
BOOL success;
HCkHttp http;
HCkHttpResponse resp;
int respStatusCode;
success = FALSE;
// This example assumes the Chilkat API to have been previously unlocked.
// See Global Unlock Sample for sample code.
http = CkHttp_Create();
// 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
CkHttp_SetRequestHeader(http,"User-Agent","MyApp (yourname@example.com)");
CkHttp_SetRequestHeader(http,"Authorization","Bearer ACCESS_TOKEN");
CkHttp_SetRequestHeader(http,"Harvest-Account-Id","ACCOUNT_ID");
resp = CkHttpResponse_Create();
success = CkHttp_HttpNoBody(http,"DELETE","https://api.harvestapp.com/v2/contacts/CONTACT_ID",resp);
if (success == FALSE) {
printf("%s\n",CkHttp_lastErrorText(http));
CkHttp_Dispose(http);
CkHttpResponse_Dispose(resp);
return;
}
respStatusCode = CkHttpResponse_getStatusCode(resp);
printf("Response Status Code = %d\n",respStatusCode);
if (respStatusCode != 200) {
printf("Response Header:\n");
printf("%s\n",CkHttpResponse_header(resp));
printf("Response Body:\n");
printf("%s\n",CkHttpResponse_bodyStr(resp));
printf("Failed.\n");
CkHttp_Dispose(http);
CkHttpResponse_Dispose(resp);
return;
}
printf("Success.\n");
CkHttp_Dispose(http);
CkHttpResponse_Dispose(resp);
}