Adaptive HTTPS
ai.https
Request
Method | Description |
request(url, method, body, headers) | Makes a HTTPS request. Returns a response.
As of 2018.3, request(method) supports
|
requestStream(url, method, body, headers
available with 2018.3 |
Makes a HTTPS stream request. Returns a response.
|
authorizedRequest(url, method, body, headers) | Makes an https request with authorization header generated for an OAuth enabled CCDS. Returns a 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. As of 2018.3, authorizedRequest(method) supports
|
RequestAuthorizedStream(url, method, body, headers)
available with 2018.3 |
Makes an HTTPS stream request with authorization header generated for an OAuth enabled CCDS. Returns a response.
Uses the underlying OAuth configuration item details along with authorization information from the data source to generate the authorization header for the https stream request. RequestAuthorizedStream(method) supports
|
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. For a complete list of HTTP response codes click here. |
getHeaders() | Returns the response headers. |
getBody() | Returns the response content. |