Outbound Calling — SOAP Call Using HTTPS POST

In this code sample, the NSOA.https.post function is used to make a SOAP call. An object is created with url, headers and body properties. The object is then passed to the NSOA.https.post function and the response returned.

Note:

Refer to the API you are calling for details on the expected request and response formats.

          /**
* SOAP call to get data center URLs using HTTPS POST method.
* @param  {Str}   accountID     ID of a NetSuite account.
* @return {Obj}                  An https.post response object.
*/
function getDataCenterUrls(accountID){


    var url = 'https://webservices.netsuite.com/services/NetSuitePort_2017_1';

    var headers = {
        'SOAPAction': 'getDataCenterUrls',
        'Content-type': 'application/javascript'
    };


    var body = '<?xml version="1.0" encoding="UTF-8"?>' +
          '<soapenv:Envelope xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:platformMsgs="urn:messages_2017_1.platform.webservices.netsuite.com">' + 
             '<soapenv:Body>'+
                '<getDataCenterUrls xsi:type="platformMsgs:GetDataCenterUrlsRequest">'+
                   '<account xsi:type="xsd:string">' + accountID + '</account>'+
                '</getDataCenterUrls>'+
             '</soapenv:Body>'+
          '</soapenv:Envelope>';


    var request = {
   url : url,
   headers: headers,
   body: body
    };  

    var response = NSOA.https.post(request);

    return response;
} 

        

See also: