Back to Collection Items
var
http: TChilkatHttp;
success: Integer;
json: TChilkatJsonObject;
sbRequestBody: TChilkatStringBuilder;
resp: IChilkatHttpResponse;
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.
// {
// "staff": {
// "vis_state": 1
// }
// }
json := TChilkatJsonObject.Create(Self);
json.UpdateInt('staff.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('PUT','https://api.freshbooks.com/accounting/account/{{accountId}}/users/staffs/{{staffId}}',sbRequestBody.ControlInterface,'utf-8','application/json',0,0);
if (http.LastMethodSuccess = 0) then
begin
Memo1.Lines.Add(http.LastErrorText);
Exit;
end;
Memo1.Lines.Add(IntToStr(resp.StatusCode));
Memo1.Lines.Add(resp.BodyStr);
Curl Command
curl -X PUT
-H "Authorization: Bearer <access_token>"
-H "Content-Type: application/json"
-d '{
"staff": {
"vis_state": 1
}
}'
https://api.freshbooks.com/accounting/account/{{accountId}}/users/staffs/{{staffId}}
Postman Collection Item JSON
{
"name": "Delete Staff",
"request": {
"method": "PUT",
"header": [
{
"key": "Content-Type",
"name": "Content-Type",
"value": "application/json",
"type": "text"
}
],
"body": {
"mode": "raw",
"raw": "{\n \"staff\": {\n \"vis_state\": 1\n }\n}"
},
"url": {
"raw": "https://api.freshbooks.com/accounting/account/{{accountId}}/users/staffs/{{staffId}}",
"protocol": "https",
"host": [
"api",
"freshbooks",
"com"
],
"path": [
"accounting",
"account",
"{{accountId}}",
"users",
"staffs",
"{{staffId}}"
]
}
},
"response": [
{
"name": "Delete Staff",
"originalRequest": {
"method": "PUT",
"header": [
{
"key": "Content-Type",
"name": "Content-Type",
"value": "application/json",
"type": "text"
}
],
"body": {
"mode": "raw",
"raw": "{\n \"staff\": {\n \"vis_state\": 1\n }\n}"
},
"url": {
"raw": "https://api.freshbooks.com/accounting/account/{{accountId}}/users/staffs/{{staffId}}",
"protocol": "https",
"host": [
"api",
"freshbooks",
"com"
],
"path": [
"accounting",
"account",
"{{accountId}}",
"users",
"staffs",
"{{staffId}}"
]
}
},
"status": "FORBIDDEN",
"code": 403,
"_postman_previewlanguage": "json",
"header": [
{
"key": "Server",
"value": "nginx"
},
{
"key": "Content-Type",
"value": "application/json"
},
{
"key": "X-NewRelic-App-Data",
"value": "PxQBWV5TCBABVlVSAwEOVlcTGhE1AwE2QgNWEVlbQFtcCxYnRA9QFg1ZWU4DFVdfRgFPCkNFR0gRQlNBEVwQFlEEXkAUCBgCHVUBVQdTAlNdBwdTUlQAAwJTTVEOHRVSXQQCB1EHAVIGBF1XXAtREB8DWA1CBG4="
},
{
"key": "Access-Control-Allow-Origin",
"value": "*"
},
{
"key": "Content-Encoding",
"value": "gzip"
},
{
"key": "Via",
"value": "1.1 google"
},
{
"key": "Via",
"value": "1.1 varnish"
},
{
"key": "Transfer-Encoding",
"value": "chunked"
},
{
"key": "Accept-Ranges",
"value": "bytes"
},
{
"key": "Date",
"value": "Wed, 24 Apr 2019 18:33:53 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": "Vary",
"value": "Accept-Encoding"
},
{
"key": "Country",
"value": "CA"
},
{
"key": "Strict-Transport-Security",
"value": "max-age=31536000; includeSubDomains; preload"
}
],
"cookie": [
],
"body": "{\n \"response\": {\n \"errors\": [\n {\n \"errno\": 1003,\n \"field\": null,\n \"message\": \"Permission Denied.\",\n \"object\": null,\n \"value\": null\n }\n ]\n }\n}"
}
]
}