PowerBuilder / New FreshBooks / Delete Bill
Back to Collection Items
integer li_rc
oleobject loo_Http
integer li_Success
oleobject loo_Json
oleobject loo_SbRequestBody
oleobject loo_Resp
oleobject loo_SbResponseBody
oleobject loo_JResp
integer li_RespStatusCode
string ls_AmountAmount
string ls_AmountCode
string ls_Category
integer li_Categoryid
string ls_CategoryCreated_at
integer li_CategoryId
integer li_Is_cogs
integer li_Is_editable
string ls_Parentid
string ls_CategoryUpdated_at
integer li_CategoryVis_state
string ls_Description
integer li_Id
integer li_List_index
string ls_Quantity
string ls_Tax_amount1
string ls_Tax_amount2
string ls_Tax_authorityid1
string ls_Tax_authorityid2
string ls_Tax_name1
string ls_Tax_name2
string ls_Tax_percent1
string ls_Tax_percent2
string ls_Total_amountAmount
string ls_Total_amountCode
string ls_Unit_costAmount
string ls_Unit_costCode
string ls_Amount
string ls_Code
string ls_Attachment
string ls_Bill_number
string ls_Created_at
string ls_Currency_code
string ls_Due_date
integer li_Due_offset_days
integer li_Id
string ls_Issue_date
string ls_Language
string ls_OutstandingAmount
string ls_OutstandingCode
string ls_Overall_category
string ls_Overall_description
string ls_PaidAmount
string ls_PaidCode
string ls_Status
string ls_Tax_amountAmount
string ls_Tax_amountCode
string ls_Total_amountAmount
string ls_Total_amountCode
string ls_Updated_at
integer li_Vis_state
integer i
integer li_Count_i
// This example assumes the Chilkat API to have been previously unlocked.
// See Global Unlock Sample for sample code.
loo_Http = create oleobject
// Use "Chilkat_9_5_0.Http" for versions of Chilkat < 10.0.0
li_rc = loo_Http.ConnectToNewObject("Chilkat.Http")
if li_rc < 0 then
destroy loo_Http
MessageBox("Error","Connecting to COM object failed")
return
end if
// Use this online tool to generate code from sample JSON: Generate Code to Create JSON
// The following JSON is sent in the request body.
// {
// "bill": {
// "vis_state": 1
// }
// }
loo_Json = create oleobject
// Use "Chilkat_9_5_0.JsonObject" for versions of Chilkat < 10.0.0
li_rc = loo_Json.ConnectToNewObject("Chilkat.JsonObject")
loo_Json.UpdateInt("bill.vis_state",1)
// Adds the "Authorization: Bearer <access_token>" header.
loo_Http.AuthToken = "<access_token>"
loo_SbRequestBody = create oleobject
// Use "Chilkat_9_5_0.StringBuilder" for versions of Chilkat < 10.0.0
li_rc = loo_SbRequestBody.ConnectToNewObject("Chilkat.StringBuilder")
loo_Json.EmitSb(loo_SbRequestBody)
loo_Resp = loo_Http.PTextSb("PUT","https://api.freshbooks.com/accounting/account/{{accountId}}/bills/bills/{{billId}}",loo_SbRequestBody,"utf-8","application/json",0,0)
if loo_Http.LastMethodSuccess = 0 then
Write-Debug loo_Http.LastErrorText
destroy loo_Http
destroy loo_Json
destroy loo_SbRequestBody
return
end if
loo_SbResponseBody = create oleobject
// Use "Chilkat_9_5_0.StringBuilder" for versions of Chilkat < 10.0.0
li_rc = loo_SbResponseBody.ConnectToNewObject("Chilkat.StringBuilder")
loo_Resp.GetBodySb(loo_SbResponseBody)
loo_JResp = create oleobject
// Use "Chilkat_9_5_0.JsonObject" for versions of Chilkat < 10.0.0
li_rc = loo_JResp.ConnectToNewObject("Chilkat.JsonObject")
loo_JResp.LoadSb(loo_SbResponseBody)
loo_JResp.EmitCompact = 0
Write-Debug "Response Body:"
Write-Debug loo_JResp.Emit()
li_RespStatusCode = loo_Resp.StatusCode
Write-Debug "Response Status Code = " + string(li_RespStatusCode)
if li_RespStatusCode >= 400 then
Write-Debug "Response Header:"
Write-Debug loo_Resp.Header
Write-Debug "Failed."
destroy loo_Resp
destroy loo_Http
destroy loo_Json
destroy loo_SbRequestBody
destroy loo_SbResponseBody
destroy loo_JResp
return
end if
destroy loo_Resp
// Sample JSON response:
// (Sample code for parsing the JSON response is shown below)
// {
// "response": {
// "result": {
// "bill": {
// "amount": {
// "amount": "5.00",
// "code": "CAD"
// },
// "attachment": null,
// "bill_number": null,
// "bill_payments": [
// ],
// "created_at": "2020-10-07 21:33:27",
// "currency_code": "CAD",
// "due_date": "2020-11-06",
// "due_offset_days": 30,
// "id": 3,
// "issue_date": "2020-10-07",
// "language": "en",
// "lines": [
// {
// "amount": {
// "amount": "5.00",
// "code": "CAD"
// },
// "category": {
// "category": "Advertising",
// "categoryid": 65688,
// "created_at": "2016-11-17 14:22:35",
// "id": 65688,
// "is_cogs": true,
// "is_editable": false,
// "parentid": null,
// "updated_at": "2020-08-14 12:52:33",
// "vis_state": 0
// },
// "description": "Food",
// "id": 5,
// "list_index": 1,
// "quantity": "1",
// "tax_amount1": null,
// "tax_amount2": null,
// "tax_authorityid1": null,
// "tax_authorityid2": null,
// "tax_name1": null,
// "tax_name2": null,
// "tax_percent1": null,
// "tax_percent2": null,
// "total_amount": {
// "amount": "5.00",
// "code": "CAD"
// },
// "unit_cost": {
// "amount": "5.00",
// "code": "CAD"
// }
// },
// {
// "amount": {
// "amount": "0.00",
// "code": "CAD"
// },
// "category": {
// "category": "Advertising",
// "categoryid": 65688,
// "created_at": "2016-11-17 14:22:35",
// "id": 65688,
// "is_cogs": true,
// "is_editable": false,
// "parentid": null,
// "updated_at": "2020-08-14 12:52:33",
// "vis_state": 0
// },
// "description": null,
// "id": 7,
// "list_index": 2,
// "quantity": "1",
// "tax_amount1": null,
// "tax_amount2": null,
// "tax_authorityid1": null,
// "tax_authorityid2": null,
// "tax_name1": null,
// "tax_name2": null,
// "tax_percent1": null,
// "tax_percent2": null,
// "total_amount": {
// "amount": "0.00",
// "code": "CAD"
// },
// "unit_cost": {
// "amount": "0.00",
// "code": "CAD"
// }
// }
// ],
// "outstanding": {
// "amount": "5.00",
// "code": "CAD"
// },
// "overall_category": "Advertising",
// "overall_description": "Food",
// "paid": {
// "amount": "0.00",
// "code": "CAD"
// },
// "status": "unpaid",
// "tax_amount": {
// "amount": "0.00",
// "code": "CAD"
// },
// "total_amount": {
// "amount": "5.00",
// "code": "CAD"
// },
// "updated_at": "2020-10-09 15:41:35",
// "vis_state": 1
// }
// }
// }
// }
// Sample code for parsing the JSON response...
// Use this online tool to generate parsing code from sample JSON: Generate JSON Parsing Code
ls_Amount = loo_JResp.StringOf("response.result.bill.amount.amount")
ls_Code = loo_JResp.StringOf("response.result.bill.amount.code")
ls_Attachment = loo_JResp.StringOf("response.result.bill.attachment")
ls_Bill_number = loo_JResp.StringOf("response.result.bill.bill_number")
ls_Created_at = loo_JResp.StringOf("response.result.bill.created_at")
ls_Currency_code = loo_JResp.StringOf("response.result.bill.currency_code")
ls_Due_date = loo_JResp.StringOf("response.result.bill.due_date")
li_Due_offset_days = loo_JResp.IntOf("response.result.bill.due_offset_days")
li_Id = loo_JResp.IntOf("response.result.bill.id")
ls_Issue_date = loo_JResp.StringOf("response.result.bill.issue_date")
ls_Language = loo_JResp.StringOf("response.result.bill.language")
ls_OutstandingAmount = loo_JResp.StringOf("response.result.bill.outstanding.amount")
ls_OutstandingCode = loo_JResp.StringOf("response.result.bill.outstanding.code")
ls_Overall_category = loo_JResp.StringOf("response.result.bill.overall_category")
ls_Overall_description = loo_JResp.StringOf("response.result.bill.overall_description")
ls_PaidAmount = loo_JResp.StringOf("response.result.bill.paid.amount")
ls_PaidCode = loo_JResp.StringOf("response.result.bill.paid.code")
ls_Status = loo_JResp.StringOf("response.result.bill.status")
ls_Tax_amountAmount = loo_JResp.StringOf("response.result.bill.tax_amount.amount")
ls_Tax_amountCode = loo_JResp.StringOf("response.result.bill.tax_amount.code")
ls_Total_amountAmount = loo_JResp.StringOf("response.result.bill.total_amount.amount")
ls_Total_amountCode = loo_JResp.StringOf("response.result.bill.total_amount.code")
ls_Updated_at = loo_JResp.StringOf("response.result.bill.updated_at")
li_Vis_state = loo_JResp.IntOf("response.result.bill.vis_state")
i = 0
li_Count_i = loo_JResp.SizeOfArray("response.result.bill.bill_payments")
do while i < li_Count_i
loo_JResp.I = i
i = i + 1
loop
i = 0
li_Count_i = loo_JResp.SizeOfArray("response.result.bill.lines")
do while i < li_Count_i
loo_JResp.I = i
ls_AmountAmount = loo_JResp.StringOf("response.result.bill.lines[i].amount.amount")
ls_AmountCode = loo_JResp.StringOf("response.result.bill.lines[i].amount.code")
ls_Category = loo_JResp.StringOf("response.result.bill.lines[i].category.category")
li_Categoryid = loo_JResp.IntOf("response.result.bill.lines[i].category.categoryid")
ls_CategoryCreated_at = loo_JResp.StringOf("response.result.bill.lines[i].category.created_at")
li_CategoryId = loo_JResp.IntOf("response.result.bill.lines[i].category.id")
li_Is_cogs = loo_JResp.BoolOf("response.result.bill.lines[i].category.is_cogs")
li_Is_editable = loo_JResp.BoolOf("response.result.bill.lines[i].category.is_editable")
ls_Parentid = loo_JResp.StringOf("response.result.bill.lines[i].category.parentid")
ls_CategoryUpdated_at = loo_JResp.StringOf("response.result.bill.lines[i].category.updated_at")
li_CategoryVis_state = loo_JResp.IntOf("response.result.bill.lines[i].category.vis_state")
ls_Description = loo_JResp.StringOf("response.result.bill.lines[i].description")
li_Id = loo_JResp.IntOf("response.result.bill.lines[i].id")
li_List_index = loo_JResp.IntOf("response.result.bill.lines[i].list_index")
ls_Quantity = loo_JResp.StringOf("response.result.bill.lines[i].quantity")
ls_Tax_amount1 = loo_JResp.StringOf("response.result.bill.lines[i].tax_amount1")
ls_Tax_amount2 = loo_JResp.StringOf("response.result.bill.lines[i].tax_amount2")
ls_Tax_authorityid1 = loo_JResp.StringOf("response.result.bill.lines[i].tax_authorityid1")
ls_Tax_authorityid2 = loo_JResp.StringOf("response.result.bill.lines[i].tax_authorityid2")
ls_Tax_name1 = loo_JResp.StringOf("response.result.bill.lines[i].tax_name1")
ls_Tax_name2 = loo_JResp.StringOf("response.result.bill.lines[i].tax_name2")
ls_Tax_percent1 = loo_JResp.StringOf("response.result.bill.lines[i].tax_percent1")
ls_Tax_percent2 = loo_JResp.StringOf("response.result.bill.lines[i].tax_percent2")
ls_Total_amountAmount = loo_JResp.StringOf("response.result.bill.lines[i].total_amount.amount")
ls_Total_amountCode = loo_JResp.StringOf("response.result.bill.lines[i].total_amount.code")
ls_Unit_costAmount = loo_JResp.StringOf("response.result.bill.lines[i].unit_cost.amount")
ls_Unit_costCode = loo_JResp.StringOf("response.result.bill.lines[i].unit_cost.code")
i = i + 1
loop
destroy loo_Http
destroy loo_Json
destroy loo_SbRequestBody
destroy loo_SbResponseBody
destroy loo_JResp
Curl Command
curl -X PUT
-H "Authorization: Bearer <access_token>"
-d '{
"bill": {
"vis_state": 1
}
}'
https://api.freshbooks.com/accounting/account/{{accountId}}/bills/bills/{{billId}}
Postman Collection Item JSON
{
"name": "Delete Bill",
"request": {
"method": "PUT",
"header": [
],
"body": {
"mode": "raw",
"raw": "{\n \"bill\": {\n \"vis_state\": 1\n }\n}",
"options": {
"raw": {
"language": "json"
}
}
},
"url": {
"raw": "https://api.freshbooks.com/accounting/account/{{accountId}}/bills/bills/{{billId}}",
"protocol": "https",
"host": [
"api",
"freshbooks",
"com"
],
"path": [
"accounting",
"account",
"{{accountId}}",
"bills",
"bills",
"{{billId}}"
]
}
},
"response": [
{
"name": "Delete Bill",
"originalRequest": {
"method": "PUT",
"header": [
],
"body": {
"mode": "raw",
"raw": "{\n \"bill\": {\n \"vis_state\": 1\n }\n}",
"options": {
"raw": {
"language": "json"
}
}
},
"url": {
"raw": "https://api.freshbooks.com/accounting/account/{{accountId}}/bills/bills/{{billId}}",
"protocol": "https",
"host": [
"api",
"freshbooks",
"com"
],
"path": [
"accounting",
"account",
"{{accountId}}",
"bills",
"bills",
"{{billId}}"
]
}
},
"status": "OK",
"code": 200,
"_postman_previewlanguage": "json",
"header": [
{
"key": "Server",
"value": "nginx"
},
{
"key": "Date",
"value": "Fri, 09 Oct 2020 15:41:35 GMT"
},
{
"key": "Content-Type",
"value": "application/json"
},
{
"key": "Vary",
"value": "Accept-Encoding"
},
{
"key": "X-NewRelic-App-Data",
"value": "PxQBWV5TCBABVlVSAwEOVlcTGhE1AwE2QgNWEVlbQFtcCxYnRA9QFg1ZWU4DFVdfRgFPCkNFR0gGWFpfEVwBC1wOGk4IFAQcAFEJUQRSA1pVAwZTUlYJAgdIVVQbEwRfUAMGBgRUWlAIUwBQXAAWHlUEVRJUPA=="
},
{
"key": "X-Frame-Options",
"value": "SAMEORIGIN"
},
{
"key": "X-XSS-Protection",
"value": "1; mode=block"
},
{
"key": "X-Content-Type-Options",
"value": "nosniff"
},
{
"key": "Content-Security-Policy",
"value": "default-src 'self'"
},
{
"key": "X-Content-Security-Policy",
"value": "default-src 'self'"
},
{
"key": "Strict-Transport-Security",
"value": "max-age=31556926; includeSubDomains; preload"
},
{
"key": "Referrer-Policy",
"value": "strict-origin-when-cross-origin"
},
{
"key": "X-RateLimit-Limit",
"value": "600"
},
{
"key": "X-RateLimit-Remaining",
"value": "599"
},
{
"key": "X-RateLimit-Reset",
"value": "1602258156"
},
{
"key": "Retry-After",
"value": "60"
},
{
"key": "Access-Control-Allow-Origin",
"value": "*"
},
{
"key": "Content-Encoding",
"value": "gzip"
},
{
"key": "Via",
"value": "1.1 google"
},
{
"key": "Alt-Svc",
"value": "h3-Q050=\":443\"; ma=2592000,h3-Q046=\":443\"; ma=2592000,h3-Q043=\":443\"; ma=2592000,quic=\":443\"; ma=2592000; v=\"46,43\""
},
{
"key": "Transfer-Encoding",
"value": "chunked"
}
],
"cookie": [
],
"body": "{\n \"response\": {\n \"result\": {\n \"bill\": {\n \"amount\": {\n \"amount\": \"5.00\",\n \"code\": \"CAD\"\n },\n \"attachment\": null,\n \"bill_number\": null,\n \"bill_payments\": [],\n \"created_at\": \"2020-10-07 21:33:27\",\n \"currency_code\": \"CAD\",\n \"due_date\": \"2020-11-06\",\n \"due_offset_days\": 30,\n \"id\": 3,\n \"issue_date\": \"2020-10-07\",\n \"language\": \"en\",\n \"lines\": [\n {\n \"amount\": {\n \"amount\": \"5.00\",\n \"code\": \"CAD\"\n },\n \"category\": {\n \"category\": \"Advertising\",\n \"categoryid\": 65688,\n \"created_at\": \"2016-11-17 14:22:35\",\n \"id\": 65688,\n \"is_cogs\": true,\n \"is_editable\": false,\n \"parentid\": null,\n \"updated_at\": \"2020-08-14 12:52:33\",\n \"vis_state\": 0\n },\n \"description\": \"Food\",\n \"id\": 5,\n \"list_index\": 1,\n \"quantity\": \"1\",\n \"tax_amount1\": null,\n \"tax_amount2\": null,\n \"tax_authorityid1\": null,\n \"tax_authorityid2\": null,\n \"tax_name1\": null,\n \"tax_name2\": null,\n \"tax_percent1\": null,\n \"tax_percent2\": null,\n \"total_amount\": {\n \"amount\": \"5.00\",\n \"code\": \"CAD\"\n },\n \"unit_cost\": {\n \"amount\": \"5.00\",\n \"code\": \"CAD\"\n }\n },\n {\n \"amount\": {\n \"amount\": \"0.00\",\n \"code\": \"CAD\"\n },\n \"category\": {\n \"category\": \"Advertising\",\n \"categoryid\": 65688,\n \"created_at\": \"2016-11-17 14:22:35\",\n \"id\": 65688,\n \"is_cogs\": true,\n \"is_editable\": false,\n \"parentid\": null,\n \"updated_at\": \"2020-08-14 12:52:33\",\n \"vis_state\": 0\n },\n \"description\": null,\n \"id\": 7,\n \"list_index\": 2,\n \"quantity\": \"1\",\n \"tax_amount1\": null,\n \"tax_amount2\": null,\n \"tax_authorityid1\": null,\n \"tax_authorityid2\": null,\n \"tax_name1\": null,\n \"tax_name2\": null,\n \"tax_percent1\": null,\n \"tax_percent2\": null,\n \"total_amount\": {\n \"amount\": \"0.00\",\n \"code\": \"CAD\"\n },\n \"unit_cost\": {\n \"amount\": \"0.00\",\n \"code\": \"CAD\"\n }\n }\n ],\n \"outstanding\": {\n \"amount\": \"5.00\",\n \"code\": \"CAD\"\n },\n \"overall_category\": \"Advertising\",\n \"overall_description\": \"Food\",\n \"paid\": {\n \"amount\": \"0.00\",\n \"code\": \"CAD\"\n },\n \"status\": \"unpaid\",\n \"tax_amount\": {\n \"amount\": \"0.00\",\n \"code\": \"CAD\"\n },\n \"total_amount\": {\n \"amount\": \"5.00\",\n \"code\": \"CAD\"\n },\n \"updated_at\": \"2020-10-09 15:41:35\",\n \"vis_state\": 1\n }\n }\n }\n}"
}
]
}