Back to Collection Items
var
http: TChilkatHttp;
success: Integer;
json: TChilkatJsonObject;
sbRequestBody: TChilkatStringBuilder;
resp: IChilkatHttpResponse;
sbResponseBody: TChilkatStringBuilder;
jResp: TChilkatJsonObject;
respStatusCode: Integer;
begin
// This example assumes the Chilkat API to have been previously unlocked.
// See Global Unlock Sample for sample code.
http := TChilkatHttp.Create(Self);
// Use this online tool to generate code from sample JSON: Generate Code to Create JSON
// The following JSON is sent in the request body.
// {
// "project": {
// "vis_state": 1
// }
// }
json := TChilkatJsonObject.Create(Self);
json.UpdateInt('project.vis_state',1);
// Adds the "Authorization: Bearer <access_token>" header.
http.AuthToken := '<access_token>';
http.SetRequestHeader('Content-Type','application/json');
sbRequestBody := TChilkatStringBuilder.Create(Self);
json.EmitSb(sbRequestBody.ControlInterface);
resp := http.PTextSb('DELETE','https://my.freshbooks.com/service/api/comments/business/{{businessId}}/project/{{projectId}}',sbRequestBody.ControlInterface,'utf-8','application/json',0,0);
if (http.LastMethodSuccess = 0) then
begin
Memo1.Lines.Add(http.LastErrorText);
Exit;
end;
sbResponseBody := TChilkatStringBuilder.Create(Self);
resp.GetBodySb(sbResponseBody.ControlInterface);
jResp := TChilkatJsonObject.Create(Self);
jResp.LoadSb(sbResponseBody.ControlInterface);
jResp.EmitCompact := 0;
Memo1.Lines.Add('Response Body:');
Memo1.Lines.Add(jResp.Emit());
respStatusCode := resp.StatusCode;
Memo1.Lines.Add('Response Status Code = ' + IntToStr(respStatusCode));
if (respStatusCode >= 400) then
begin
Memo1.Lines.Add('Response Header:');
Memo1.Lines.Add(resp.Header);
Memo1.Lines.Add('Failed.');
Exit;
end;
Curl Command
curl -X DELETE
-H "Authorization: Bearer <access_token>"
-H "Content-Type: application/json"
-d '{
"project": {
"vis_state": 1
}
}'
https://my.freshbooks.com/service/api/comments/business/{{businessId}}/project/{{projectId}}
Postman Collection Item JSON
{
"name": "Delete Project",
"request": {
"method": "DELETE",
"header": [
{
"key": "Content-Type",
"name": "Content-Type",
"value": "application/json",
"type": "text"
}
],
"body": {
"mode": "raw",
"raw": "{\n \"project\": {\n \"vis_state\": 1\n }\n}"
},
"url": {
"raw": "https://my.freshbooks.com/service/api/comments/business/{{businessId}}/project/{{projectId}}",
"protocol": "https",
"host": [
"my",
"freshbooks",
"com"
],
"path": [
"service",
"api",
"comments",
"business",
"{{businessId}}",
"project",
"{{projectId}}"
]
}
},
"response": [
{
"name": "Delete Project",
"originalRequest": {
"method": "PUT",
"header": [
{
"key": "Content-Type",
"name": "Content-Type",
"value": "application/json",
"type": "text"
}
],
"body": {
"mode": "raw",
"raw": "{\n \"project\": {\n \"vis_state\": 1\n }\n}"
},
"url": {
"raw": "https://api.freshbooks.com/projects/business/{{businessId}}/projects/{{projectId}}",
"protocol": "https",
"host": [
"api",
"freshbooks",
"com"
],
"path": [
"projects",
"business",
"{{businessId}}",
"projects",
"{{projectId}}"
]
}
},
"status": "NOT FOUND",
"code": 404,
"_postman_previewlanguage": "json",
"header": [
{
"key": "Server",
"value": "nginx"
},
{
"key": "Content-Type",
"value": "application/vnd.api+json"
},
{
"key": "X-Version",
"value": "1904.6.0"
},
{
"key": "Access-Control-Allow-Origin",
"value": "*"
},
{
"key": "Via",
"value": "1.1 google"
},
{
"key": "Via",
"value": "1.1 varnish"
},
{
"key": "Content-Length",
"value": "79"
},
{
"key": "Accept-Ranges",
"value": "bytes"
},
{
"key": "Date",
"value": "Wed, 24 Apr 2019 18:25:22 GMT"
},
{
"key": "Connection",
"value": "keep-alive"
},
{
"key": "X-Served-By",
"value": "cache-mdw17369-MDW"
},
{
"key": "X-Cache",
"value": "MISS"
},
{
"key": "X-Cache-Hits",
"value": "0"
},
{
"key": "Country",
"value": "CA"
},
{
"key": "Strict-Transport-Security",
"value": "max-age=31536000; includeSubDomains; preload"
}
],
"cookie": [
],
"body": "{\n \"error_type\": \"not_found\",\n \"message\": \"The requested resource was not found.\"\n}"
},
{
"name": "Delete Project",
"originalRequest": {
"method": "DELETE",
"header": [
{
"key": "Content-Type",
"name": "Content-Type",
"value": "application/json",
"type": "text"
}
],
"body": {
"mode": "raw",
"raw": "{\n \"project\": {\n \"vis_state\": 1\n }\n}"
},
"url": {
"raw": "https://my.freshbooks.com/service/api/comments/business/{{businessId}}/project/{{projectId}}",
"protocol": "https",
"host": [
"my",
"freshbooks",
"com"
],
"path": [
"service",
"api",
"comments",
"business",
"{{businessId}}",
"project",
"{{projectId}}"
]
}
},
"status": "NO CONTENT",
"code": 204,
"_postman_previewlanguage": "json",
"header": [
{
"key": "Server",
"value": "nginx"
},
{
"key": "Content-Type",
"value": "application/vnd.api+json"
},
{
"key": "X-Version",
"value": "1904.25.0"
},
{
"key": "X-NewRelic-App-Data",
"value": "PxQBWV5TCBABVllUBAQOU10TGhE1AwE2QgNWEVlbQFtcCxYnRA9QFg1ZWU4FDFZFVRYSBxlDUhULRERQBxVNEkINUgdbTBpAVhZWFEMCVlgURFgLAwBMERxUTVIZAQFSXQYCBFpSW1cBUg9WCgoYBgJJG1IAVVBRB1BWAldTCQADU1RAG1dWChdUaw=="
},
{
"key": "Access-Control-Allow-Origin",
"value": "*"
},
{
"key": "Expires",
"value": "Tue, 24 Apr 2018 18:28:35 GMT"
},
{
"key": "Cache-Control",
"value": "no-cache"
},
{
"key": "X-Frame-Options",
"value": "SAMEORIGIN"
},
{
"key": "Via",
"value": "1.1 google"
},
{
"key": "Via",
"value": "1.1 varnish"
},
{
"key": "Accept-Ranges",
"value": "bytes"
},
{
"key": "Date",
"value": "Wed, 24 Apr 2019 18:28:35 GMT"
},
{
"key": "Connection",
"value": "keep-alive"
},
{
"key": "X-Served-By",
"value": "cache-mdw17328-MDW"
},
{
"key": "X-Cache",
"value": "MISS"
},
{
"key": "X-Cache-Hits",
"value": "0"
},
{
"key": "Country",
"value": "CA"
},
{
"key": "Strict-Transport-Security",
"value": "max-age=31536000; includeSubDomains; preload"
}
],
"cookie": [
],
"body": null
}
]
}