Using RESTlet with NetSuite Connector Guide

October 13 2016

6 comments 0
netsuite-connector-banners

You can find our NetSuite Connector and other NetSuite related connectors on our MuleSoft Exchange page here.

NetSuite offers many different ways to communicate with NetSuite: , , and others. While SuiteTalk is a standard SOAP API, NetSuite users can develop their own custom integration with SuiteScript (similar to JavaScript) and expose it as a RESTFul API through . Once it is exposed through , users can call this API directly with the HTTP Request in Studio or through their preferred browsers, but they need to configure HTTP header with the proper authentication method (i.e. NLAuth nlauth_account=YOURACCOUNT,nlauth_email=YOUREMAILADDRESS,
nlauth_signature=PASSWORDS,nlauth_role=YOURROLE).

With Anypoint Connector for NetSuite v7.3.0, after users configure the connector as they would to use SuiteTalk (SOAP API), they can easily make a RESTlet call with the GET/POST/PUT/DELETE methods. The following shows how to create a RESTlet in NetSuite and use it with Anypoint Connector for NetSuite v7.3.0.

First, we need to create a custom integration in JavaScript in NetSuite and expose it through RESTlet.

JavaScript example

The following JavaScript example is provided in the NetSuite RESTlet document. Create a sample.js file based on the example:

Configure NetSuite to expose your SuiteScript(JavaScript) through RESTlet.

  1. Enable SuiteScript and Web Services under Setup -> Company -> Enable Features -> SuiteCloud.
    screen-shot-2016-10-04-at-5-21-06-pm
  2. Create a new script and upload the script file you created in the previous step. Go to Customization > Scripting > Scripts > New.
  3. Select the sample.js, click on “Create Script Record,” and select “Restlet.”screen-shot-2016-10-04-at-5-21-15-pm
  4. Fill out the following form based on the sample.js, and “Deploy Script.”
  5. screen-shot-2016-10-04-at-5-21-25-pmAfter you set your “Audience,” you will see the following image. The script value and the deploy value (i.e. script=547&depoly=1) in the External URL will be used for the NetSuite Connector to call the RESTlet.
    screen-shot-2016-10-04-at-5-21-37-pm

Installing the

Now, you are ready to call your first RESTlet with the updated NetSuite Connector. Before you move on to the next step, please make sure you have the right version of the connector downloaded from the Exchange.

screen-shot-2016-09-20-at-11-33-48-am

 

Import/Configure a RESTlet

Find the demo-restlet app from this page, and import it to Studio. The following demo app is preconfigured to work with the SuiteScript example above.

screen-shot-2016-09-20-at-11-50-58-am

Once you import the demo app, select “Global Element” and open the NetSuite Configuration by clicking on “Edit”.

screen-shot-2016-09-20-at-11-53-36-am

Make sure RESTlet endpoint and Endpoint has the right values for your NetSuite environment. You can specify your NetSuite configuration directly here, but I recommend you use the mule-app.properties. In mule-app.properties, configure the following keys:

netsuite.email=
netsuite.password=
netsuite.account=
netsuite.roleId=
netsuite.applicationId=
netsuite.script=547 (Your Script value from the External URL)
netsuite.deploy=1

Run the Restlet demo

After you start the demo app in Studio and hit localhost:8081/ with your browser. You will see a simple HTML page allowing you to interact with this demo app for “Insert Record” (Post), “Get Record” (Get) and “Delete Record” (Delete).

screen-shot-2016-09-20-at-3-54-16-pm

When using Get Record with ID = 500 and Record Type = Customer, the following is the response I receive:

For new users, try the above example to get started, and for others, please share with us how you use or are planning to use the NetSuite Connector! Also, explore the Anypoint Exchange to see other resources you can leverage today.


 


We'd love to hear your opinion on this post

6 Responses to “Using RESTlet with NetSuite Connector Guide”

  1. What are the advantages of this over using plain http?

    Agree(0)Disagree(0)Comment
    • Ryan,

      You can use the plain http to do the same thing, but if your integration requires SOAP (SuiteTalk) and RESTlet (SuiteScript), NetSuite Connector can cover both of them.

      Thanks,
      Nathan

      Agree(0)Disagree(0)Comment
  2. hi Nathan

    I am trying to to call RESTLet from studio using HTTP call. I have RESTLet developed in netsuite and I can make a call using POSTMAN. But in MuleSoft HTTP connector requires port, what port I need to supply? I tried with 443 and I am getting error “An unexpected error has occurred. Please click here to notify support and provide your contact information.”. Please help.

    -Samir

    Agree(0)Disagree(0)Comment
    • Samir,

      Have you tried the RESTlet with NetSuite Connector? It would be easier for you to use it.

      For HTTP Requests, the following configuration should work.

      Agree(0)Disagree(0)Comment
      • hi,
        how can i call my restlet that deploye in netsuite i have tired plz help

        Agree(0)Disagree(0)Comment
  3. Netsuite SuiteScript is really very useful for make the apps with API, its can make the things as we like or user likes, thank you for information and for the code for optimizing.

    Agree(0)Disagree(0)Comment