Error: ‘Could not cast or convert from System.String to UiPath.Models.WorkflowFileInfo.’ when calling via REST

robot
api

#1

I have a Flow with just “open browser IE and URL”, have latest Community Edition, and the execution logs show just execution started and executions ended.

I have no Issues with Studio Execution, also running a Batch command is fine:

./UiRobot.exe -file “C:\workspaces\UIPath\job.xaml”

but if I try to start via REST from Powershell using following commands

$job ="{‘WorkflowFile’: ‘C:\workspaces\UIPath\job.xaml’, ‘User’: ‘myuser’, ‘Password’: ‘******’, ‘Type’: 0}"
$jobIdResponse = Invoke-RestMethod -Uri http://127.0.0.1:8080/UiPath/service/agent/StartJob -Body $job -Method Post
$jobId = $jobIdResponse.ChildNodes[0].InnerText

here I get the Error: ‘Could not cast or convert from System.String to UiPath.Models.WorkflowFileInfo.’
Tried to use ‘Postman’ as well … same result.

all fine here as well

Invoke-RestMethod http://127.0.0.1:8080/UiPath/service/agent/IsAlive -Method Get

this one shows … true

Tried in the meantime also different Paths, warning this Forum change them as well :slight_smile:

‘C:\\workspaces\\UIPath\\job.xaml’ (two backward slashes)
‘C:\workspaces\UIPath\job.xaml’ (one backward slash, should be wrong)
‘C:/workspaces/UIPath/job.xaml’ (one forward slashes, works in batch)

I run my UiPath on a notebook i7 and windows 10.


#2

I have the same exact issue with the start Job via Rest using Powershell.

The IsAlive works fine but I get the Could not cast or convert from System.String to UiPath.Models.WorkflowFileInfo as well.

Please let me know if you find a solution to this :smiley:


#3

have no Solution yet, still stuck here with the REST call, … as said all fine using CMD Batch command.
And Suggestions? … or areas to check for?

thanks, Jörg


#4

Using Windows 10 64bit, with .NET version 4.7.02556 installed.


#5

I’m experiencing exactly same problem with licensed robot.
isAlive returns True, but StartJob fails with following error message.

  Request Error
  The server encountered an error processing the request. The exception message is 'Could not cast or convert from System.String to 
UiPath.Models.WorkflowFileInfo.'. See server logs for more details. The exception stack trace is: 
     at UiPath.Broker.UiPathRemote.StartJob(Stream jobInfo)
   at SyncInvokeStartJob(Object , Object[] , Object[] )
   at System.ServiceModel.Dispatcher.SyncMethodInvoker.Invoke(Object instance, Object[] inputs, Object[]& outputs)
   at System.ServiceModel.Dispatcher.DispatchOperationRuntime.InvokeBegin(MessageRpc& rpc)
   at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage5(MessageRpc& rpc)
   at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage41(MessageRpc& rpc)
   at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage4(MessageRpc& rpc)
   at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage31(MessageRpc& rpc)
   at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage3(MessageRpc& rpc)
   at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage2(MessageRpc& rpc)
   at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage11(MessageRpc& rpc)
   at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage1(MessageRpc& rpc)
   at System.ServiceModel.Dispatcher.MessageRpc.Process(Boolean isOperationContextSet)

This is the same error from Event Log with verbose logging. It seems that the problem is how the workflow path is given.

 {"message":"StartJob : Newtonsoft.Json, \n Newtonsoft.Json.JsonSerializationException: Error converting value \"C:\\RPA\\UiPathTest\\TriggerTest\\Pull.xaml\" to type 'UiPath.Models.WorkflowFileInfo'. Path 'WorkflowFile', line 1, position 62. ---> System.ArgumentException: Could not cast or convert from System.String to UiPath.Models.WorkflowFileInfo.\r\n   at Newtonsoft.Json.Utilities.ConvertUtils.EnsureTypeAssignable(Object value, Type initialType, Type targetType)\r\n   at Newtonsoft.Json.Utilities.ConvertUtils.ConvertOrCast(Object initialValue, CultureInfo culture, Type targetType)\r\n   at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.EnsureType(JsonReader reader, Object value, CultureInfo culture, JsonContract contract, Type targetType)\r\n   --- End of inner exception stack trace ---\r\n   at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.EnsureType(JsonReader reader, Object value, CultureInfo culture, JsonContract contract, Type targetType)\r\n   at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateValueInternal(JsonReader reader, Type objectType, JsonContract contract, JsonProperty member, JsonContainerContract containerContract, JsonProperty containerMember, Object existingValue)\r\n   at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.SetPropertyValue(JsonProperty property, JsonConverter propertyConverter, JsonContainerContract containerContract, JsonProperty containerProperty, JsonReader reader, Object target)\r\n   at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.PopulateObject(Object newObject, JsonReader reader, JsonObjectContract contract, JsonProperty member, String id)\r\n   at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateObject(JsonReader reader, Type objectType, JsonContract contract, JsonProperty member, JsonContainerContract containerContract, JsonProperty containerMember, Object existingValue)\r\n   at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateValueInternal(JsonReader reader, Type objectType, JsonContract contract, JsonProperty member, JsonContainerContract containerContract, JsonProperty containerMember, Object existingValue)\r\n   at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.Deserialize(JsonReader reader, Type objectType, Boolean checkAdditionalContent)\r\n   at Newtonsoft.Json.JsonSerializer.DeserializeInternal(JsonReader reader, Type objectType)\r\n   at Newtonsoft.Json.JsonConvert.DeserializeObject(String value, Type type, JsonSerializerSettings settings)\r\n   at Newtonsoft.Json.JsonConvert.DeserializeObject[T](String value, JsonSerializerSettings settings)\r\n   at UiPath.Shared.JsonParser.SimpleDeserializeObject[T](String jsonValue)\r\n   at UiPath.Broker.UiPathRemote.StartJob(Stream jobInfo)","level":"Error","logType":"Default","timeStamp":"2018-03-22T07:47:17.3016828+00:00","fingerprint":"25067946-c5b2-4a7f-bd0b-6a4c31468a11"}

#6

Did any of you find solution here?


#7

No … I’m still getting the error.


#8

UIpath Support stated: “It was supported before v2016.2. The support was removed for later versions
That’s a reason a note is already mentioned at start of document, Note: The Robot API is no longer supported. We recommend using the Orchestrator API.”