Skip to main content
Adaptive Insights
Knowledge and Support - Adaptive Insights

Adaptive HTTPS

ai.https

Request

Method Description
request(url, method, body, headers) Makes a HTTPS request. Returns a HTTPS response.
authorizedRequest(url, method, body, headers) Makes an https request with authorization header generated for OAuth enabled Data Source. Returns a https response.

Uses the underlying OAuth configuration item details along with authorization information from the data source to generate the authorization header for the https request

 

Examples

function makeHttpRequest(context) {
     var url = 'https://www.intacct.com/ia/xml/xmlgw.phtml';
     var method = 'POST';
     var body = '<request><control><senderid>adaptiveplanning</senderid><password>Bts9DrRkeZ</password><controlid>SomethingToMapRequestToResponse</controlid><dtdversion>3.0</dtdversion></control><operation><authentication><login><userid>Julia</userid><companyid>companyplanning‑DEV</companyid><password>GhY93tYi</password></login></authentication><content><function controlid="SomethingToMapRequestToResponse"><readByQuery><object>' + tableId + '</object><fields>' + columnNames.join(",") + '</fields><query></query><pagesize>' + maxRows + '</pagesize><returnFormat>json</returnFormat></readByQuery> </function></content></operation></request>';    var headers = { 'Content-Type': 'x-intacct-xml-request' }
     // Step 3: Send https request and receive response. Normally you would want to check that the response contains a success message first before looking at the rows.    var response = ai.https.request(url, method, body, headers);     return response;} 
function makeAuthorizedHttpRequest(context) {
     var dataSource = context.getDataSource();
     var companyId = dataSource.getSetting("Company Id").getValue();
     var url = 'https://sandbox-quickbooks.api.intuit.com/v3/company/' + companyId + '/account/1';
     var method = 'GET';
     var body = '';
     var headers = { 'Accept': 'application/json' };
      
     // Step 3: Send https authorized request and receive response. Normally you would want to check that the response contains a success message first before looking at the rows.
    var response = ai.https.authorizedRequest(url, method, body, headers);
 
    return response;
}

Response

Method Description
getHttpCode() Returns the HTTP code of the response.
getHeaders() Returns the response headers.
getBody() Returns the response content.
  • Was this article helpful?