Passer au contenu principal
Adaptive Planning
Dernière mise à jour : 2023-06-23
sendAndGetXML_Intacct

sendAndGetXML_Intacct

Ce script de démarrage CCDS doit être modifié par un développeurs JavaScript pour votre cas d’utilisation. Il ne fonctionnera pas sans modification.
Enregistrez le bloc de codes ci-dessous en tant que script dans votre CCDS Intacct SAGE et nommez-le 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(); }