PowerBuilder / New FreshBooks / Edit Vendor Details
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_Amount
string ls_Code
string ls_Account_number
string ls_City
string ls_Country
string ls_Created_at
string ls_Currency_code
integer li_Is_1099
string ls_Language
string ls_Phone
string ls_Postal_code
string ls_Primary_contact_email
string ls_Primary_contact_first_name
string ls_Primary_contact_last_name
string ls_Province
string ls_Street
string ls_Street2
string ls_Updated_at
string ls_Vendor_name
integer li_Vendorid
integer li_Vis_state
string ls_Website
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_vendor": {
// "vendor_name": "IKEA",
// "primary_contact_first_name": "Jimmy",
// "primary_contact_last_name": "McNamara",
// "primary_contact_email": "jimmym@ikea.com",
// "primary_contact": null,
// "street": "332 Carlton Ave.",
// "street2": null,
// "city": "San Francisco",
// "province": "California",
// "postal_code": null,
// "country": "United States",
// "account_number": "45454545",
// "phone": "4158859378",
// "website": "ikea.com",
// "currency_code": "USD",
// "language": "en",
// "is_1099": false,
// "tax_defaults": [
// ]
// }
// }
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.UpdateString("bill_vendor.vendor_name","IKEA")
loo_Json.UpdateString("bill_vendor.primary_contact_first_name","Jimmy")
loo_Json.UpdateString("bill_vendor.primary_contact_last_name","McNamara")
loo_Json.UpdateString("bill_vendor.primary_contact_email","jimmym@ikea.com")
loo_Json.UpdateNull("bill_vendor.primary_contact")
loo_Json.UpdateString("bill_vendor.street","332 Carlton Ave.")
loo_Json.UpdateNull("bill_vendor.street2")
loo_Json.UpdateString("bill_vendor.city","San Francisco")
loo_Json.UpdateString("bill_vendor.province","California")
loo_Json.UpdateNull("bill_vendor.postal_code")
loo_Json.UpdateString("bill_vendor.country","United States")
loo_Json.UpdateString("bill_vendor.account_number","45454545")
loo_Json.UpdateString("bill_vendor.phone","4158859378")
loo_Json.UpdateString("bill_vendor.website","ikea.com")
loo_Json.UpdateString("bill_vendor.currency_code","USD")
loo_Json.UpdateString("bill_vendor.language","en")
loo_Json.UpdateBool("bill_vendor.is_1099",0)
loo_Json.UpdateNewArray("bill_vendor.tax_defaults")
// 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}}/bill_vendors/bill_vendors/{{vendorId}}",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_vendor": {
// "account_number": "45454545",
// "city": "San Francisco",
// "country": "United States",
// "created_at": "2020-10-09 15:25:05",
// "currency_code": "USD",
// "is_1099": false,
// "language": "en",
// "outstanding_balance": [
// {
// "amount": {
// "amount": "450.00",
// "code": "USD"
// }
// }
// ],
// "overdue_balance": [
// ],
// "phone": "4158859378",
// "postal_code": null,
// "primary_contact_email": "jimmym@ikea.com",
// "primary_contact_first_name": "Jimmy",
// "primary_contact_last_name": "McNamara",
// "province": "California",
// "street": "332 Carlton Ave.",
// "street2": null,
// "tax_defaults": [
// ],
// "updated_at": "2020-10-09 15:39:10",
// "vendor_name": "IKEA",
// "vendorid": 5,
// "vis_state": 0,
// "website": "ikea.com"
// }
// }
// }
// }
// Sample code for parsing the JSON response...
// Use this online tool to generate parsing code from sample JSON: Generate JSON Parsing Code
ls_Account_number = loo_JResp.StringOf("response.result.bill_vendor.account_number")
ls_City = loo_JResp.StringOf("response.result.bill_vendor.city")
ls_Country = loo_JResp.StringOf("response.result.bill_vendor.country")
ls_Created_at = loo_JResp.StringOf("response.result.bill_vendor.created_at")
ls_Currency_code = loo_JResp.StringOf("response.result.bill_vendor.currency_code")
li_Is_1099 = loo_JResp.BoolOf("response.result.bill_vendor.is_1099")
ls_Language = loo_JResp.StringOf("response.result.bill_vendor.language")
ls_Phone = loo_JResp.StringOf("response.result.bill_vendor.phone")
ls_Postal_code = loo_JResp.StringOf("response.result.bill_vendor.postal_code")
ls_Primary_contact_email = loo_JResp.StringOf("response.result.bill_vendor.primary_contact_email")
ls_Primary_contact_first_name = loo_JResp.StringOf("response.result.bill_vendor.primary_contact_first_name")
ls_Primary_contact_last_name = loo_JResp.StringOf("response.result.bill_vendor.primary_contact_last_name")
ls_Province = loo_JResp.StringOf("response.result.bill_vendor.province")
ls_Street = loo_JResp.StringOf("response.result.bill_vendor.street")
ls_Street2 = loo_JResp.StringOf("response.result.bill_vendor.street2")
ls_Updated_at = loo_JResp.StringOf("response.result.bill_vendor.updated_at")
ls_Vendor_name = loo_JResp.StringOf("response.result.bill_vendor.vendor_name")
li_Vendorid = loo_JResp.IntOf("response.result.bill_vendor.vendorid")
li_Vis_state = loo_JResp.IntOf("response.result.bill_vendor.vis_state")
ls_Website = loo_JResp.StringOf("response.result.bill_vendor.website")
i = 0
li_Count_i = loo_JResp.SizeOfArray("response.result.bill_vendor.outstanding_balance")
do while i < li_Count_i
loo_JResp.I = i
ls_Amount = loo_JResp.StringOf("response.result.bill_vendor.outstanding_balance[i].amount.amount")
ls_Code = loo_JResp.StringOf("response.result.bill_vendor.outstanding_balance[i].amount.code")
i = i + 1
loop
i = 0
li_Count_i = loo_JResp.SizeOfArray("response.result.bill_vendor.overdue_balance")
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_vendor.tax_defaults")
do while i < li_Count_i
loo_JResp.I = i
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_vendor": {
"vendor_name": "IKEA",
"primary_contact_first_name": "Jimmy",
"primary_contact_last_name": "McNamara",
"primary_contact_email": "jimmym@ikea.com",
"primary_contact": null,
"street": "332 Carlton Ave.",
"street2": null,
"city": "San Francisco",
"province": "California",
"postal_code": null,
"country": "United States",
"account_number": "45454545",
"phone": "4158859378",
"website": "ikea.com",
"currency_code": "USD",
"language": "en",
"is_1099": false,
"tax_defaults": []
}
}'
https://api.freshbooks.com/accounting/account/{{accountId}}/bill_vendors/bill_vendors/{{vendorId}}
Postman Collection Item JSON
{
"name": "Edit Vendor Details",
"request": {
"method": "PUT",
"header": [
],
"body": {
"mode": "raw",
"raw": "{\n \"bill_vendor\": {\n \"vendor_name\": \"IKEA\",\n \"primary_contact_first_name\": \"Jimmy\",\n \"primary_contact_last_name\": \"McNamara\",\n \"primary_contact_email\": \"jimmym@ikea.com\",\n \"primary_contact\": null,\n \"street\": \"332 Carlton Ave.\",\n \"street2\": null,\n \"city\": \"San Francisco\",\n \"province\": \"California\",\n \"postal_code\": null,\n \"country\": \"United States\",\n \"account_number\": \"45454545\",\n \"phone\": \"4158859378\",\n \"website\": \"ikea.com\",\n \"currency_code\": \"USD\",\n \"language\": \"en\",\n \"is_1099\": false,\n \"tax_defaults\": []\n }\n}",
"options": {
"raw": {
"language": "json"
}
}
},
"url": {
"raw": "https://api.freshbooks.com/accounting/account/{{accountId}}/bill_vendors/bill_vendors/{{vendorId}}",
"protocol": "https",
"host": [
"api",
"freshbooks",
"com"
],
"path": [
"accounting",
"account",
"{{accountId}}",
"bill_vendors",
"bill_vendors",
"{{vendorId}}"
]
}
},
"response": [
{
"name": "Edit Vendor Details",
"originalRequest": {
"method": "PUT",
"header": [
],
"body": {
"mode": "raw",
"raw": "{\n \"bill_vendor\": {\n \"vendor_name\": \"IKEA\",\n \"primary_contact_first_name\": \"Jimmy\",\n \"primary_contact_last_name\": \"McNamara\",\n \"primary_contact_email\": \"jimmym@ikea.com\",\n \"primary_contact\": null,\n \"street\": \"332 Carlton Ave.\",\n \"street2\": null,\n \"city\": \"San Francisco\",\n \"province\": \"California\",\n \"postal_code\": null,\n \"country\": \"United States\",\n \"account_number\": \"45454545\",\n \"phone\": \"4158859378\",\n \"website\": \"ikea.com\",\n \"currency_code\": \"USD\",\n \"language\": \"en\",\n \"is_1099\": false,\n \"tax_defaults\": []\n }\n}",
"options": {
"raw": {
"language": "json"
}
}
},
"url": {
"raw": "https://api.freshbooks.com/accounting/account/{{accountId}}/bill_vendors/bill_vendors/{{vendorId}}",
"protocol": "https",
"host": [
"api",
"freshbooks",
"com"
],
"path": [
"accounting",
"account",
"{{accountId}}",
"bill_vendors",
"bill_vendors",
"{{vendorId}}"
]
}
},
"status": "OK",
"code": 200,
"_postman_previewlanguage": "json",
"header": [
{
"key": "Server",
"value": "nginx"
},
{
"key": "Date",
"value": "Fri, 09 Oct 2020 15:39:09 GMT"
},
{
"key": "Content-Type",
"value": "application/json"
},
{
"key": "Vary",
"value": "Accept-Encoding"
},
{
"key": "X-NewRelic-App-Data",
"value": "PxQBWV5TCBABVlVSAwEOVlcTGhE1AwE2QgNWEVlbQFtcCxYnRA9QFg1ZWU4DFVdfRgFPCkNFR0gGWFpfPRAGDFQNShECWl1eXxNcD1UOQUBIBhtRSFUICgJcUFcECA5XUggPAVBKVVYIThpWD11XUAJXXAcHAFdQAFNRQ0oFWV9DATw="
},
{
"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": "1602258010"
},
{
"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_vendor\": {\n \"account_number\": \"45454545\",\n \"city\": \"San Francisco\",\n \"country\": \"United States\",\n \"created_at\": \"2020-10-09 15:25:05\",\n \"currency_code\": \"USD\",\n \"is_1099\": false,\n \"language\": \"en\",\n \"outstanding_balance\": [\n {\n \"amount\": {\n \"amount\": \"450.00\",\n \"code\": \"USD\"\n }\n }\n ],\n \"overdue_balance\": [],\n \"phone\": \"4158859378\",\n \"postal_code\": null,\n \"primary_contact_email\": \"jimmym@ikea.com\",\n \"primary_contact_first_name\": \"Jimmy\",\n \"primary_contact_last_name\": \"McNamara\",\n \"province\": \"California\",\n \"street\": \"332 Carlton Ave.\",\n \"street2\": null,\n \"tax_defaults\": [],\n \"updated_at\": \"2020-10-09 15:39:10\",\n \"vendor_name\": \"IKEA\",\n \"vendorid\": 5,\n \"vis_state\": 0,\n \"website\": \"ikea.com\"\n }\n }\n }\n}"
}
]
}