This article demonstrates creating a public integrator.io API to run an existing export.
A. Write the script
- From the Resources menu, select Scripts.
- At the right, click + Create script.
- Name your new script (ex. MyAPI – export Example).
- Write the JavaScript code in the Edit content field.
- The script must have at least one entry-point function – _mainExport() below.
- It must handle any errors.
- In this case, it calls exports.run(), passing it the export’s ID, as shown below:
import { exports } from 'integrator-api' function _mainExport (options) { let response = {}; let invokeExportResponse; let exportResponse; // Execute the export try { invokeExportResponse = exports.run({_id:'5ef••••••••••••••••••b01'}); response.statusCode = 200; }catch(e) { invokeExportResponse = JSON.stringify(e); response.statusCode = 400; } // Create body response
response.body = {
exportResponse: invokeExportResponse
} return { statusCode: response.statusCode, headers: { }, body: response.body } }
- Save the script.
B. Create the My API
- Navigate to Resources > My APIs.
- Click + Create My API at the upper right.
- Enter a name (ex. Demo – export).
- Select the script saved in step A (MyAPI – export).
- Click to open the Script editor and copy the function name (_mainExport). Paste the name into the Function field.
- Click Save & close.
C. Get an API token
- Navigate to Resources > API token.
- Click + Create API token at the upper right.
- Enter a name (ex. Postman My API).
- In the Token permissions section, select Custom scopes.
- From the My APIs list, select the My API you created in step B, Demo – export.
- Click Save & close.
See full example
Comments
I do have a export which have more than 11k data , but only retrieve less than that from MYAPI . is there anyway i can do a paging or retrieve data from netsuite export using MYAPI ?
Please sign in to leave a comment.