Global API
...
Request
Item
Create
1min
You can use the below request code to create an Item in Xero.
Request
Response
1// Create a Map to store all the data
2Map<String, Object> itemMap = new Map<String, Object>();
3itemMap.put('Name', 'GenWatt Diesel 200kWk');
4itemMap.put('Code', 'GC10402');
5
6Map<String, Object> salesDetailsMap = new Map<String, Object>();
7salesDetailsMap.put('UnitPrice', '210');
8salesDetailsMap.put('TaxType', 'OUTPUT');
9salesDetailsMap.put('AccountCode', '260');
10itemMap.put('SalesDetails', salesDetailsMap);
11itemMap.put('IsSold', true);
12itemMap.put('Description', 'Item Description item-gold');
13
14Map<String, Object> purchaseDetailsMap = new Map<String, Object>();
15purchaseDetailsMap.put('UnitPrice', '100');
16purchaseDetailsMap.put('TaxType', 'INPUT');
17purchaseDetailsMap.put('COGSAccountCode', '260');
18itemMap.put('PurchaseDetails', purchaseDetailsMap);
19itemMap.put('IsPurchased', true);
20itemMap.put('PurchaseDescription', 'Purchase Item Description - item-gold');
21itemMap.put('IsTrackedAsInventory', false);
22itemMap.put('QuantityOnHand', '0');
23itemMap.put('TotalCostPool', '0');
24itemMap.put('InventoryAssetAccountCode','630');
25
26Map<String, Object> requestJSONMap = new Map<String, Object>();
27requestJSONMap.put('items', new List<Object>{itemMap});
28String reqJSON = JSON.serialize(requestJSONMap);
29
30Map<String, Object> reqObj = new Map<String, Object>();
31reqObj.put('version', '1.0');
32reqObj.put('action', 'createItem');
33reqObj.put('requestJSON', reqJSON);
34
35// Placing a request to Breadwinner Global API
36Map<String, Object> respMap = Bread_winner.BreadwinnerXeroAPI.call(reqObj);
37System.debug(respMap);