The SuiteTalk platform integrates NetSuite with a variety of on-premise applications and third-party cloud environments by leveraging CSV, SOAP and REST web services. This can be used to build website-to-NetSuite integrations or custom mobile applications. NetSuite’s REST web services provide a REST-based interface for interacting with NetSuite and extend the capabilities of SuiteTalk.

NetSuite’s REST web service is an easy-to-navigate API, giving users access to company-specific records metadata. It allows for easy handling of custom records and fields, and no requirement for users to write, deploy and run custom scripts as in the case of RESTlets. This API is still in the beta stage in Netsuite, but the Integration team at Tvarana has successfully integrated it with the Mulesoft platform using OAuth2 to fetch data from NetSuite.

Oauth 2.0 authentication of Netsuite in Mulesoft Anypoint Studio has been configured as follows:

 

1.Add a listener to the flow and give the respective listener configuration and path.

2. Drag and drop a HTTP Request operation from Mule palette.

NetSuite OAuth2 Mulesoft Anypoint Studio Integration

 

3. Request Configuration for Netsuite Oauth Authentication:

  • Add a Request configuration, change the name of the configuration as required, and select the protocol from the given drop-down list (HTTPS)
  • Enter the host as <netsuite-account-id>.suitetalk.api.netsuite.com
  • The base path would be /services/rest/record/v1
  • In the Authentication Type as “Authorization Code grant type” (if this authentication type is not available in the drop down then you haven’t added the Oauth module).

 

NetSuite OAuth2 Mulesoft Anypoint Studio integration

 

  • The Local Callback configuration, shown in the figure above, uses a different Listener configuration for the callback. The Listener configuration would look like

 

NetSuite OAuth2 Mulesoft Anypoint Studio Integration

 

  • Click Ok to return to the Request Configuration. Add /callback as the Local Callback configuration path. The external callback URL is the redirect URL entered in the users’s NetSuite account. State value can be any random string like (ykv2XLx1BpT5Q0F3MRPHb94l)
  • Local Authorization URL is the main URL through which incoming requests are sent and outgoing requests are received. It is important to note that the Local Authorization URL and Local Callback URL must have the same port and cannot be left empty. The Local Authorization URL would be https://localhost:8082/web
  • The Authorization URL for Netsuite is https://<netsuite-account-id>.app.netsuite.com/app/login/oauth2/authorize.nl
  • Enter the values of client ID and client secret, generated when creating the NetSuite Integration Record.The scope would be rest_webservices
  • The token for NetSuite is https://<netsuite-account-id>.suitetalk.api.netsuite.com/services/rest/auth/oauth2/v1/token
  • Check to ensure that all details entered are correct and save the configuration

 

NetSuite OAuth2 Mulesoft Anypoint Studio Integration

 

 

NetSuite OAuth2 Mulesoft Anypoint Studio Integration

  • In the Mulesoft console, the error message looks like the screenshot below

 

NetSuite OAuth2 Mulesoft Anypoint Integration

  • This error has occurred because an access token was not generated. In order to generate the access token, the Local Authorization URL needs to be triggered. Once this is done, the user will be redirected to Netsuite Login page

 

NetSuite OAuth2 Mulesoft Anypoint Integration

 

  • After logging into their NetSuite account, the user is redirected to the permission page, seen in the screenshot below

 

NetSuite OAuth2 Mulesoft Anypoint Integration

 

  • Click on continue to be redirected to a page with the message- Successfully retrieved access token

 

NetSuite OAuth2 Mulesoft Anypoint Integration

  • This completes the generation of access token. Now trigger the listener to view the result, in this case, the list of customers (the result is in the form of URLs)

 

NetSuite OAuth2 Mulesoft Anypoint Integration

 

 

Tvarana’s team of integration experts can develop APIs based on your business’ unique requirements. Set up a consultation to find out how.

 

Please follow and like us: