3

I'm doing Salesforce-Netsuite Integration.I need to call Sales force Rest API in schedule script.How to do this? Can anyone help me?

Revathi
  • 41
  • 4

1 Answers1

2

I'm not sure what the Salesforce REST API URL would be (I personally use JitterBit for my integrations, so that I don't have to constantly monitor anything and I can go on vacation. ;) ). That being said, in NetSuite, you can call any URL with the https/http modules. See a simple example below.

require(['N/https'],function(https){
  function sendData(){
    var header=[];
    header['Content-Type']='application/json';
    var postData={"some data":data};
    var apiURL='SF_URL'

    try{
      var response=https.put({
        url:apiURL,
        headers:header,
        body:postData
      });
      log.debug('response',JSON.stringify(response));
      log.debug('response.body',JSON.stringify(response.body));
    }catch(er02){
      log.error('ERROR',JSON.stringify(er02));
    }
  }

  sendData();
});

SuiteScript 2.0 - https

SuiteScript 2.0 - http

w3bguy
  • 2,215
  • 1
  • 19
  • 34