Rest 如何从Groovy脚本语言启动UiPath Robot?

Rest 如何从Groovy脚本语言启动UiPath Robot?,rest,groovy,rpa,uipath,Rest,Groovy,Rpa,Uipath,如何从Groovy脚本语言启动UiPath Robot 我的进程在UiPath Orchestrator上,我想从Groovy向UiPath Orchestrator发送一组RESTAPI命令来启动进程 我已经阅读了,但是我无法创建一个工作脚本 其主要思想是,经过更多研究,不同的软件(例如Jira或Jenkins)使用此Groovy语言编写脚本。在这里,您可以找到在UiPath Orchestrator上启动UiPath进程的Groovy脚本代码: def builder = new groov

如何从Groovy脚本语言启动UiPath Robot

我的进程在UiPath Orchestrator上,我想从Groovy向UiPath Orchestrator发送一组RESTAPI命令来启动进程

我已经阅读了,但是我无法创建一个工作脚本


其主要思想是,经过更多研究,不同的软件(例如Jira或Jenkins)使用此Groovy语言编写脚本。

在这里,您可以找到在UiPath Orchestrator上启动UiPath进程的Groovy脚本代码:

def builder = new groovy.json.JsonBuilder();
def root = builder{
                    grant_type 'refresh_token'
                    client_id 'YOUR CLIENT ID'
                    refresh_token 'YOUR REFRESH TOKEN'
                 }
assert root instanceof Map

def link = new URL("https://account.uipath.com/oauth/token");
def connection = link.openConnection() as HttpURLConnection;

connection.setRequestProperty("Content-Type","application/json");
connection.setRequestProperty("X-UIPATH-TenantName","YOUR TENANTNAME");
connection.setDoOutput(true);

def httpRequestBodyWriter = new BufferedWriter(new OutputStreamWriter(connection.getOutputStream()))
httpRequestBodyWriter.write(builder)
httpRequestBodyWriter.close()
def auth = "0"
if(connection.responseCode == 200)
{
    def resp = connection.inputStream.text
    auth = resp.substring(resp.indexOf("access_token")+15,resp.indexOf("id_token")-3)    
    println resp
}

def builder2 = new groovy.json.JsonBuilder();
//process without parameters
/*def root2 = builder2.startInfo {
                    ReleaseKey 'YOUR PROCESS ReleaseKey'
                    Strategy 'All'
                 }*/
//process with parameters
def root2 = builder2.startInfo {
                    ReleaseKey 'YOUR PROCESS ReleaseKey'
                    Strategy 'All'
                    InputArguments '{"param1":"Test Youtube","param2":"GroovyConsole"}'
                 }
assert root2 instanceof Map

def link2 = new URL("https://platform.uipath.com/[Account Logical Name]/[Tenant Logical Name]/odata/Jobs/UiPath.Server.Configuration.OData.StartJobs");
def connection2 = link2.openConnection() as HttpURLConnection;

connection2.setRequestProperty("Authorization",'Bearer '+auth);
connection2.setRequestProperty("Content-Type","application/json");
connection2.setRequestProperty("X-UIPATH-TenantName","YOUR TENANTNAME");
connection2.setRequestProperty("User-Agent","telnet");
connection2.setDoOutput(true);

def httpRequestBodyWriter2 = new BufferedWriter(new OutputStreamWriter(connection2.getOutputStream()))
httpRequestBodyWriter2.write(builder2)
httpRequestBodyWriter2.close()

   println connection2.responseCode
   println connection2.responseMessage   

您可以通过API启动UiPath进程。你是说这个吗?请写一些关于您的问题的更多信息。是的,我们讨论通过RESTAPI启动机器人。对于每个脚本系统,都有不同的提示和技巧,从我的角度来看,最终用户可以准确地找到电影中的代码,这是非常有用的。使用SO做广告不是一件好事。我的朋友,希望你以后能用SO来提问。大家好,很抱歉造成这么多问题。我的想法是分享一个小脚本,它正在工作,为此,我提供了一个Youtube视频链接,以证明它正在工作。我不想推广,我只是分享在Salesforce、ServiceNow、NetSuite、JS、Groovy内部完成的代码。。。不是UiPath。这个想法来自一个简单的事实:过去我在YouTube上看了很多教程,当我想尝试那里的内容时,我需要重写代码。通过这种方式,观看视频的人可以非常轻松地测试代码。我的帖子是社区维基。我需要从我的答案中删除到youtube的链接?完成后,我将问题和答案修改为完全独立于youtube。这对于希望使用Groovy中的RESTAPI命令的任何人都很有用。