Xero Connector > Xero operations > Xero source operations
  

Xero source operations

Create a Source transformation in the Mapping Task wizard to read data from Xero.
To configure the Source operation, perform the following steps:
  1. 1In the Source transformation, select a Xero connection.
  2. 2On the Source tab, select an operation from the list of operations.
  3. 3Configure the request message for the operation. Copy the request message from the sample template, and edit the JSON based on your use case.

Configuring a request using Request Message Editor

When you create a Source transformation, configure a JSON request message for the operation that you want to perform in Xero.
Use the Request Message Editor to create a request message. The request message uses the JSON format and contains request parameters exposed by Xero APIs for a specific operation. You can use the default request message for the operation, and then customize it to specify the data that you want to include.
To customize your request, copy the request message from the sample template to the Request Message Editor pane where you can edit the JSON message and add the attributes for the request. Remove unnecessary and empty tags from the request message to avoid operation failure. You can hide the optional elements to see only the required elements.
Every Xero operation requires the Xero-Tenant-Id parameter, as shown in the following image:
In the request message template, the Hide optional elements check box is selected, and the template shows only the required Xero-Tenant-Id parameter.
To retrieve accounts, use the getAccounts operation and add the where and order query parameters to return only active bank accounts sorted by name. The following sample request message shows these parameters:
{
"Xero-Tenant-Id" : "8fc87e03-8401-4024-bbac-798790a98425",
"If-Modified-Since" : "",
"where" : "Status==\"ACTIVE\" AND Type==\"BANK\"",
"order" : "Name ASC"
}
To retrieve invoices that have specific statuses, use the getInvoices operation and specify the Xero-Tenant-Id, Statuses, and summaryOnly parameters in the request message. The following sample request message shows these parameters:
{
"Xero-Tenant-Id" : "cd13c0ac-db47-4b44-ab1f-9970127655c9",
"Statuses" : [ "AUTHORISED", "PAID" ],
"summaryOnly" : "True"
}
The following image shows the request message template and a request message configured to filter invoices by status in the Mapping Designer:
In the Request Message Editor, the request message template at the top lists the empty parameters for the operation. Below the template, the Request Message section shows a request message with an example configuration.
Note:
When you pass array parameters, such as Statuses or ContactIDs, pass them as comma-separated strings. For example: [ “AUTHORISED”, “PAID”]
The request message format in Xero Connector follows the service request definition in Xero. Use well-formed JSON in the request message, and include the parameters that you need for your use case.

Field mapping in a Source transformation

The response message format follows the service response definition in Xero. You can map response fields from a hierarchical to a relational structure of output groups and fields.
After you configure an operation for a source and specify the request message, create the relational format from the hierarchical data to include groups and fields that you want in the output.
Select the elements in the response structure that you want to include as output fields. The Secure Agent converts the JSON response in the hierarchical structure to relational groups at run time.
The following image shows an example hierarchical response structure generated for the getAccounts operation, and the corresponding relational output fields for the response:
In the field mapping for the getAccounts operation, the hierarchical response elements on the left map to the relational output fields on the right.
You can edit the data type, precision, and scale for the groups and fields after mapping the fields.
For more information about field mapping, see Transformations.