sendAndGetXML_Intacct
JavaScript 开发者必须根据您的用例修改此 CCDS 起始脚本。如果不进行修改,它将无法运行。
在 SAGE Intacct CCDS 中将以下代码块另存为脚本,并将其命名为 sendAndGetXML_Intacct。
function sendAndGetXML_Intacct(intacctURL,strXMLRequest) { //Make the request to Intacct and look for errors in the result //The actual request is in strXMLRequest in fully formed XML //If no errors found then return the body of the response to the caller, otherwise return false. //The caller is responsible for checking the response and parsing out the payload. //Create a https request to send to Intacct API var url = intacctURL; var method = 'POST'; var body = strXMLRequest; var headers = { 'Content-Type': 'x-intacct-xml-request' }; var response, responseBody; //Send request and receive response try { response = ai.https.request(url, method, body, headers); } catch(e) { //catastrophic failure ai.log.logError('Intacct Request Failed','Intacct request failed. Error: ' + e + ' req: ' + body); return false; } //verify a good http return code var httpCode = response.getHttpCode(); if (httpCode != '200') { ai.log.logError('Intacct Request Failed','Intacct request failed. Http response code: ' + httpCode); return false; } return response.getBody(); }