Articles in this section

Set up My API to run an export

This article demonstrates creating a public integrator.io API to run an existing export.

A. Write the script

  1. From the Resources menu, select Scripts
  2. At the right, click + Create script.
  3. Name your new script (ex. MyAPI – export Example).
  4. 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 } }
  1. Save the script. 

B. Create the My API

  1. Navigate to Resources > My APIs
  2. Click + Create My API at the upper right. 
  3. Enter a name (ex. Demo – export).
  4. Select the script saved in step A (MyAPI – export).
  5. Click to open the Script editor and copy the function name (_mainExport). Paste the name into the Function field.
  6. Click Save & close.

C. Get an API token

  1. Navigate to Resources > API token
  2. Click + Create API token at the upper right. 
  3. Enter a name (ex. Postman My API).
  4. In the Token permissions section, select Custom scopes.
  5. From the My APIs list, select the My API you created in step B, Demo – export.
  6. Click Save & close.

See full example

Was this article helpful?
0 out of 0 found this helpful

Comments

1 comment
Date Votes
  • 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 ? 

    0

Please sign in to leave a comment.