In order to call functions in the integrator.io API JavaScript runtime module, it’s important to understand the structure of the JSON data objects. For example, to run a virtual export, you must know which fields are required and what data type to provide for each.
This tutorial sends a GET request to the integrator.io REST API for an example export created in the user interface, in order to examine the retrieved export object schema.
Steps
- A. Get the ID for an existing export resource
- B. Get the export definition
- C. Extract export object definition from the response
A. Get the ID for an existing export resource
Open an existing export resource in integrator.io and copy the ID from the URI, as described in Retrieve the resource ID.
Sample masked IDs – such as 5c6••••••••••••••••••3fb – are referenced below.
B. Get the export definition
Then, using an API testing software, such as Postman, place the following request, where my_api_token is an API token with permission for the export with the specified ID:
GET /v1/exports/5c6••••••••••••••••••3fb HTTP/1.1
Host: api.staging.integrator.io
Authorization: Bearer my_api_token
Sample response
{
"_id": "5ea••••••••••••••••••06f",
"createdAt": "2020-05-01T23:54:24.116Z",
"lastModified": "2020-08-11T22:05:31.240Z",
"name": "Get NetSuite invoices that are above x amount (invoked by My API)",
"description": "Get all invoices from NetSuite",
"_connectionId": "5e9••••••••••••••••••6e0",
"apiIdentifier": "e7d2a66a3d",
"asynchronous": true,
"pageSize": 3,
"_templateId": "5c3••••••••••••••••••8f1",
"rawData": "5d9d235ed4fed53523cf42d1e0cd8fd6dc0f4c00a9b6b20b5b82e42d",
"netsuite": {
"type": "restlet",
"skipGrouping": true,
"statsOnly": false,
"restlet": {
"recordType": "invoice",
"searchId": "6763",
"criteria": [
{
"field": "amount",
"operator": "greaterthan",
"searchValue": "15000"
}
]
},
"distributed": {
"disabled": false,
"forceReload": false,
"executionContext": [
"userinterface",
"webstore"
],
"executionType": [
"create",
"edit",
"xedit"
]
}
},
"transform": {
"type": "expression",
"expression": {
"rules": [],
"version": "1"
},
"version": "1",
"rules": []
},
"filter": {
"type": "expression",
"expression": {
"version": "1"
},
"version": "1"
},
"inputFilter": {
"type": "expression",
"expression": {
"version": "1"
},
"version": "1"
},
"adaptorType": "NetSuiteExport"
}
C. Extract export object definition from the response
For advanced developers, the field names and sample values should be self-explanatory.
Continuing with this sample NetSuite export definition, the following fields would be required when using the JavaScript runtime to create an export or run a virtual export, by passing them in a function argument that takes an options
object:
{
"_connectionId": "5e9••••••••••••••••••6e0",
"netsuite": {
"type": "restlet",
"skipGrouping": true,
"statsOnly": false,
"restlet": {
"recordType": "invoice",
"searchId": "6763",
"criteria": [
{
"field": "amount",
"operator": "greaterthan",
"searchValue": "<replace with amount>"
}
]
},
"distributed": {
"disabled": false,
"forceReload": false,
"executionContext": [
"userinterface",
"webstore"
],
"executionType": [
"create",
"edit",
"xedit"
]
}
},
"adaptorType": "NetSuiteExport"
}
Tip: The search criteria, above, is not required for every export; it is provided here for demonstration purposes.
Optional fields
Not all exports require transform or filter rules to be defined, such as the following fields:
"transform": {
"type": "expression",
"expression": {
"rules": [],
"version": "1"
},
"version": "1",
"rules": []
},
"filter": {
"type": "expression",
"expression": {
"version": "1"
},
"version": "1"
},
"inputFilter": {
"type": "expression",
"expression": {
"version": "1"
},
"version": "1"
Comments
0 comments
Please sign in to leave a comment.