Website logo
Product Overview
NetSuite
Payments
QuickBooks
Xero
Navigate through spaces
⌘K
Getting Started
Guided Wizard
Guided Wizard Settings
Custom Guided Wizard
Button URL Structure
Button URL Generator
Support
Global API
API Overview
Request
Response
Code Examples
Advanced Topics
Batch Invoicing
Technical Resources
Breadwinner Setup
Requirements
ERD / Object Structure
Getting Help
Version History
Docs powered by Archbee
Global API
...
Request
Item

Create

1min

You can use the below request code to create an Item in Xero.

Request
Response
// Create a Map to store all the data
Map<String, Object> itemMap = new Map<String, Object>();
itemMap.put('Name', 'GenWatt Diesel 200kWk');
itemMap.put('Code', 'GC10402');

Map<String, Object> salesDetailsMap = new Map<String, Object>();
salesDetailsMap.put('UnitPrice', '210');
salesDetailsMap.put('TaxType', 'OUTPUT');
salesDetailsMap.put('AccountCode', '260');
itemMap.put('SalesDetails', salesDetailsMap);
itemMap.put('IsSold', true);
itemMap.put('Description', 'Item Description item-gold');

Map<String, Object> purchaseDetailsMap = new Map<String, Object>();
purchaseDetailsMap.put('UnitPrice', '100');
purchaseDetailsMap.put('TaxType', 'INPUT');
purchaseDetailsMap.put('COGSAccountCode', '260');
itemMap.put('PurchaseDetails', purchaseDetailsMap);
itemMap.put('IsPurchased', true);
itemMap.put('PurchaseDescription', 'Purchase Item Description - item-gold');
itemMap.put('IsTrackedAsInventory', false);
itemMap.put('QuantityOnHand', '0');
itemMap.put('TotalCostPool', '0');
itemMap.put('InventoryAssetAccountCode','630');

Map<String, Object> requestJSONMap = new Map<String, Object>();
requestJSONMap.put('items', new List<Object>{itemMap});
String reqJSON = JSON.serialize(requestJSONMap);

Map<String, Object> reqObj = new Map<String, Object>();
reqObj.put('version', '1.0');
reqObj.put('action', 'createItem');
reqObj.put('requestJSON', reqJSON);

//  Placing a request to Breadwinner Global API
Map<String, Object> respMap = Bread_winner.BreadwinnerXeroAPI.call(reqObj);
System.debug(respMap);




Updated 18 Apr 2023
Did this page help you?
PREVIOUS
Read
NEXT
Response
Docs powered by Archbee
Docs powered by Archbee