Global API
...
Request
Contact
Create
1 min
the following is an example to create a customer with every possible field available (see contact docid\ xpsz7qutzphbpo3vustz for the available fields) request // create a map to store all the data of a contact map\<string, object> contactmap = new map\<string, object>(); contactmap put('name', 'breadwinner inc'); contactmap put('firstname', 'jack'); contactmap put('lastname', 'rogers'); contactmap put('emailaddress', 'jrogers\@burlington com'); list\<object> phoneslist = new list\<object>(); map\<string, object> defaultphone = new map\<string, object>(); defaultphone put('phonetype', 'default'); defaultphone put('phonenumber', '9988543562'); phoneslist add(defaultphone); contactmap put('phones', phoneslist); list\<object> addresslist = new list\<object>(); map\<string, object> shippingaddressmap = new map\<string, object>(); shippingaddressmap put('addresstype', 'street'); shippingaddressmap put('country', 'india'); shippingaddressmap put('addressline3', 'kodad'); shippingaddressmap put('addressline2', 'first lane'); shippingaddressmap put('addressline1', '1 24'); shippingaddressmap put('postalcode', '508238'); shippingaddressmap put('city', 'suryapet'); shippingaddressmap put('region', 'india'); shippingaddressmap put('attentionto', 'user'); addresslist add(shippingaddressmap); map\<string, object> billingaddrfieldmap = new map\<string, object>(); billingaddrfieldmap put('addresstype', 'pobox'); billingaddrfieldmap put('country', 'india'); billingaddrfieldmap put('addressline3', ''); billingaddrfieldmap put('addressline2', 'srinagar colony'); billingaddrfieldmap put('addressline1', '1/78 24'); billingaddrfieldmap put('postalcode', '500008'); billingaddrfieldmap put('city', 'hyderabad'); billingaddrfieldmap put('region', 'india'); billingaddrfieldmap put('attentionto', 'user'); addresslist add(billingaddrfieldmap); contactmap put('addresses', addresslist); // initializing the requestjson data to be passed map\<string, object> requestjsonmap = new map\<string, object>(); requestjsonmap put('contacts', new list\<object>{contactmap}); string reqjson = json serialize(requestjsonmap); map\<string, object> reqobj = new map\<string, object>(); reqobj put('version', '1 0'); reqobj put('action', 'createcontact'); reqobj put('requestjson', reqjson); //required, if xero multi org is enabled in breadwinner reqobj put('xeroorgid', '!aa00tm'); // placing a request to breadwinner global api map\<string, object> respmap = bread winner breadwinnerxeroapi call(reqobj); system debug(respmap); response { action=createcontact, responsejson={ "statuscode" "200", "contacts" \[ { "website"\ null, "taxnumber"\ null, "skypeusername"\ null, "salestrackingcategories"\ null, "salesdefaultaccountcode"\ null, "salesforcerecordid" "a016o00000r0l3rqaa", "purchasestrackingcategories"\ null, "purchasesdefaultaccountcode"\ null, "phones" \[ { "phonetype" "default", "phonenumber" "9988543562", "phonecountrycode" "", "phoneareacode" "" } ], "phone"\ null, "paymentterms" { "sales"\ null, "bills"\ null }, "name" "breadwinner inc", "lastname" "rogers", "lastmodifiedinxero"\ null, "issupplier"\ null, "iscustomer"\ null, "firstname" "jack", "fax"\ null, "errormessage"\ null, "emailaddress" "jrogers\@burlington com", "discount"\ null, "defaultcurrency"\ null, "createddateinxero"\ null, "contactstatus" "active", "contactpersons" \[ { "lastname" "", "includeinemails"\ null, "firstname" "", "emailaddress" "" }, { "lastname" "", "includeinemails"\ null, "firstname" "", "emailaddress" "" }, { "lastname" "", "includeinemails"\ null, "firstname" "", "emailaddress" "" }, { "lastname" "", "includeinemails"\ null, "firstname" "", "emailaddress" "" }, { "lastname" "", "includeinemails"\ null, "firstname" "", "emailaddress" "" } ], "contactid" "950f2525 14a8 4871 8348 980d6b9c5757", "brandingtheme"\ null, "balances"\ null, "addresses" \[ { "region" "india", "postalcode" "500008", "country" "india", "city" "hyderabad", "attentionto" "user", "addresstype" "pobox", "addressline4" "", "addressline3" "", "addressline2" "srinagar colony", "addressline1" "1/78 24" } ], "accountsreceivabletaxtype"\ null, "accountspayabletaxtype"\ null, "accountnumber" "" } ], "errors" \[ ], }, timestamp=1635849847648, validrequest=true, version=1 0 }