Start job, JSON deserialization error - SOLVED

Just spent some time debugging a weird error when starting a job through the API:

    Invalid format for argument 'Arguments': Cannot deserialize the current JSON object (e.g. {"name":"value"}) into type 'Newtonsoft.Json.Linq.JToken' because the type requires a JSON array (e.g. [1,2,3]) to deserialize correctly.
To fix this error either change the JSON to a JSON array (e.g. [1,2,3]) or change the deserialized type so that it is a normal .NET type (e.g. not a primitive type like integer, not a collection type like an array or List) that can be deserialized from a JSON object. JsonObjectAttribute can also be added to the type to force it to deserialize from a JSON object.
Path 'token_code'.

RemoteException wrapping System.Exception: Invalid format for argument 'Arguments': Cannot deserialize the current JSON object (e.g. {"name":"value"}) into type 'Newtonsoft.Json.Linq.JToken' because the type requires a JSON array (e.g. [1,2,3]) to deserialize correctly.
To fix this error either change the JSON to a JSON array (e.g. [1,2,3]) or change the deserialized type so that it is a normal .NET type (e.g. not a primitive type like integer, not a collection type like an array or List) that can be deserialized from a JSON object. JsonObjectAttribute can also be added to the type to force it to deserialize from a JSON object.
Path 'token_code'. ---> RemoteException wrapping Newtonsoft.Json.JsonSerializationException: Cannot deserialize the current JSON object (e.g. {"name":"value"}) into type 'Newtonsoft.Json.Linq.JToken' because the type requires a JSON array (e.g. [1,2,3]) to deserialize correctly.
To fix this error either change the JSON to a JSON array (e.g. [1,2,3]) or change the deserialized type so that it is a normal .NET type (e.g. not a primitive type like integer, not a collection type like an array or List) that can be deserialized from a JSON object. JsonObjectAttribute can also be added to the type to force it to deserialize from a JSON object.
Path 'token_code'.
at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateObject(JsonReader reader, Type objectType, JsonContract contract, JsonProperty member, JsonContainerContract containerContract, JsonProperty containerMember, Object existingValue)
at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateValueInternal(JsonReader reader, Type objectType, JsonContract contract, JsonProperty member, JsonContainerContract containerContract, JsonProperty containerMember, Object existingValue)
at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.Deserialize(JsonReader reader, Type objectType, Boolean checkAdditionalContent)
at Newtonsoft.Json.JsonSerializer.DeserializeInternal(JsonReader reader, Type objectType)
at Newtonsoft.Json.Linq.JToken.ToObject(Type objectType, JsonSerializer jsonSerializer)
at Newtonsoft.Json.Linq.JToken.ToObject(Type objectType)
at UiPath.Executor.Utilities.WorkflowArgumentsUtilities.DeserializeArguments(DynamicActivity workflow, IDictionary`2 arguments, Boolean shouldThrow)
--- End of inner exception stack trace ---
at UiPath.Executor.Utilities.WorkflowArgumentsUtilities.DeserializeArguments(DynamicActivity workflow, IDictionary`2 arguments, Boolean shouldThrow)
at UiPath.Executor.RobotRunner.InitWorkflowApplication()
at UiPath.Executor.RobotRunner.d__78.MoveNext()

Posting the solution here in case anyone runs into it.

I had a custom activity that included the Newtonsoft.json.dll in the NuGet package. Once I removed it and updated the custom activity it worked.

2 Likes

For anyone else having this issue:

I originally fixed it as per the post above, but then it recurred even without the Newtonsoft dll.

Managed to ‘fix’ by recreating a new project and importing my components over

Let me summarize the possible solutions and mark a reply as a solution to allow users to quickly get to the answer :slight_smile:

Possible solutions as per above:

  • I had a custom activity that included the Newtonsoft.json.dll in the NuGet package. Once I removed it and updated the custom activity it worked.
  • Managed to ‘fix’ by recreating a new project and importing my components over

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.