Hi Guys,
I am trying to start a UIPath-Job in the orchestrator via a Google Appscript.
I set up my unattended Robot and it is working fine, if I start the job manually in the orchestrator or via my assistant .
But when I try to start it with a script, it fails. Actually I am trying to do what is described in the following documentation in paragraph 6.2 and 6.3:
Integration with UiPath Robotic Process Automation - Knowledge Base for DX 7 - Joget | COMMUNITY (and later on of course 6.4
)
Here is my code:
function authenticateForAT () {
var data1 = {
âgrant_typeâ: ârefresh-tokenâ,
âclient_idâ: â$ClientIDâ,
ârefresh_tokenâ: â$UserKeyâ,
};
var header1 = {
âmethodâ: âpostâ,
âcontentTypeâ: âapplication/jsonâ,
âpayloadâ: JSON.stringify(data1)
};
var response1 = UrlFetchApp.fetch(âhttps://account.uipath.com/oauth/tokenâ, header1);
var messageContent1 = response1.getContentText();
var result1 = JSON.parse(messageContent1);
var access_token = result1[âaccess_tokenâ];
processReleaseKey(access_token);
function processReleaseKey(access_token){
var header2 = {
âmethodâ: âgetâ,
âAcceptâ: âapplication/jsonâ,
âAuthorizationâ: 'Bearer â + access_token
};
var response2 = UrlFetchApp.fetch(âUiPathâ", header2);
var messageContent2 = response2.getContentText();
var result2 = JSON.parse(messageContent2);
}
I get the access token without a problem. The bizarre part is the âfetchâ method in function processReleaseKey(). I get this message from logging âresponse2â:
{âmessageâ:âYou are not authenticated!â,âerrorCodeâ:0,âresultâ:null,âtargetUrlâ:null,âsuccessâ:false,âerrorâ:{âcodeâ:0,âmessageâ:âYou are not authenticated!â,âdetailsâ:âYou should be authenticated (sign in) in order to perform this operation.â,âvalidationErrorsâ:null},âunAuthorizedRequestâ:true,â__abpâ:true}
Even more bizarre is that I can perform these tasks (and even start the job like in 6.4 of the docu) without any problems in Postman or in the cmd.
I hope you guys can help me.
