jai_kumar2
(jai kumar)
November 24, 2023, 6:12pm
1
Hi ,
I have a Console Application will send user input information and subsequently initiate a UiPath API request to invoke a process within UiPath Orchestrator.
The objective is to activate the bot upon receiving the API request, extract the accompanying information in JSON format, store it in an argument or variable, and subsequently write it to a notepad file
Any help can appreciate, Thanks in advance.
rikulsilva
(Henrique Lima da Silva)
November 24, 2023, 7:05pm
2
jai_kumar2
(jai kumar)
November 24, 2023, 7:36pm
3
Thanks for the reply.
Yes I go through this but i have no idea about hoe to connect Console App and orchestrator bot to Pass Arguments/Variable.
rikulsilva
(Henrique Lima da Silva)
November 24, 2023, 7:44pm
4
In which programming language the console application is being build ?
jai_kumar2
(jai kumar)
November 24, 2023, 8:22pm
5
using System;
using System.Net.Http;
using System.Text;
using System.Text.Json;
using System.Threading.Tasks;
class Program
{
static async Task Main()
{
string orchestratorApiEndpoint = “https://cloud.uipath.com/ ”;
string organizationName = “jai”;
string serviceInstanceLogicalName = “RPA”;
string orchestratorApiKey = “-*****- -- *****”;
string processKey = “GetRequestAPI”;
string argument = “Welcome to Family”;
await TriggerJob(orchestratorApiEndpoint, organizationName, serviceInstanceLogicalName, orchestratorApiKey, processKey, argument);
}
static async Task TriggerJob(string orchestratorApiEndpoint, string organizationName, string serviceInstanceLogicalName, string orchestratorApiKey, string processKey, string argument)
{
using (HttpClient client = new HttpClient())
{
client.BaseAddress = new Uri(orchestratorApiEndpoint);
// Ensure the correct authorization header is added
client.DefaultRequestHeaders.Add("Authorization", $"Bearer {orchestratorApiKey}");
// Log the headers for verification
Console.WriteLine("Headers:");
foreach (var header in client.DefaultRequestHeaders)
{
Console.WriteLine($"{header.Key}: {string.Join(", ", header.Value)}");
}
var startInfo = new
{
ReleaseKey = orchestratorApiKey,
Strategy = "All",
RobotIds = new string[] { },
InputArguments = $"{argument}",
RobotInfo = new
{
MachineName = "jai******'s workspace machine",
HostName = "RPA",
RobotId = "123456",
}
};
var jsonContent = new StringContent(JsonSerializer.Serialize(startInfo), Encoding.UTF8, "application/json");
Console.WriteLine("JsonContent :: " + JsonSerializer.Serialize(startInfo) + "\n\n");
string requestUrl = new Uri(client.BaseAddress + $"{organizationName}/{serviceInstanceLogicalName}" + $"/odata/Jobs/UiPath.Server.Configuration.OData.StartJobs?organizationUnitId").ToString();
Console.WriteLine("Request Url ::" + requestUrl + "\n\n");
try
{
HttpResponseMessage response = await client.PostAsync(requestUrl, jsonContent);
if (response.IsSuccessStatusCode)
{
Console.WriteLine("Job triggered successfully.");
}
else
{
Console.WriteLine($"Failed to trigger job. Status code: {response.StatusCode}");
Console.WriteLine(await response.Content.ReadAsStringAsync());
}
}
catch (Exception ex)
{
Console.WriteLine($"Error: {ex.Message}");
}
}
}
}
jai_kumar2
(jai kumar)
November 27, 2023, 2:03pm
6
Hi may I get any solution for this ?