HTTP Request getting timed out after 5 minutes using the invoke code activity.
The request is bringing in response from Postman but when same request is passed using the invoke code activity then after 5 minutes the response code 0 is returned.
Custom code:
try
{
var client = new RestSharp.RestClient(in_API_URL);
var request = new RestSharp.RestRequest(RestSharp.Method.POST);
request.AddHeader(“Content-Type”, “application/json”);
var filePath = in_doc_str;
var docType = in_doc_str_type;
var fileName = in_file_name;
var customerName = in_customer_name;
var inputValue = “{"doc_str":"”+filePath+“","doc_str_type":"”+docType+“","file_name":"”+fileName+“","customer_name":"”+customerName+“"}”;
request.AddParameter(“application/json”,inputValue, ParameterType.RequestBody);
request.Timeout = 1080000;
client.Timeout = 1800000;
IRestResponse response = client.Execute(request);
Console.WriteLine(response.Content);
out_ResponseCode = response.StatusCode.ToString();
out_ResponseContent = response.Content;
}
catch(Exception ex)
{
Console.WriteLine(ex.Message);
}
We also tried using the async coding technique but that too isn’t working:
async System.Threading.Tasks.Task MakeRequestAsync()
{
var client = new RestSharp.RestClient(in_API_URL);
client.Timeout = -1;
var request = new RestSharp.RestRequest( RestSharp.Method.POST);
request.AddHeader("Content-Type", "application/json");
var filePath = in_doc_str;
var docType = in_doc_str_type;
var fileName = in_file_name;
var customerName = in_customer_name;
var inputValue = “{"doc_str":"”+filePath+“","doc_str_type":"”+docType+“","file_name":"”+fileName+“","customer_name":"”+customerName+“"}”;
Console.WriteLine(inputValue);
request.AddParameter(“application/json”,inputValue, ParameterType.RequestBody);
IRestResponse response = await client.ExecuteAsync(request);
Console.WriteLine(response.Content);
}
Can someone provide a way to increase the timeout when we try to access API endpoint using UiPath studio, since it is already working with Postman.