javascript – Totvs Fluig – Customization – Call in REST service in beforeSendData event


Does anyone know how I can make a call to a REST service inside the beforeSendData event, here is my code (non-functional):

My objective is to execute a call in a Fluig's own REST service in order to get the details of a request (process instance).

I tried using the standard jQuery call but it didn't work, this script runs server-side.

 function beforeSendData(customFields, customFacts) {"****************teste"); customFields[0] = "1"; customFacts[0] = 10.53; var processInstanceId = getValue("WKNumProces"); var taskUserId = getValue("WKUser");"****************teste"); //Tentei usar esta API mas não funciona //Tentei usar jQuery mas também não funcionou. WCMAPI.Read({ type: "POST", url: WCMAPI.getServerURL() + '/ecm/api/rest/ecm/workflowView/findDetailsMyRequests?processInstanceId=' + processInstanceId + "&taskUserId=" + taskUserId, async: false, success: function funcao(data) {; var data = jQuery.parseJSON(txt); }, error: function (msg){"****Não funcionou********"); } }); }


I've turned your comment into an answer, so the question doesn't go unanswered, and it can help others. Accepted as correct, if applicable. I made the corrections in the variable declarations, you don't need to put var in all, just at the beginning, separating with a comma.

var url = "",
get = new org.apache.commons.httpclient.methods.GetMethod(url),
client = new org.apache.commons.httpclient.HttpClient(),
br = new,
response = "",
line = br.readLine();
 while(line != null)
   response = response + line; 
   line = br.readLine()
Scroll to Top