My workflow works on it's own but doesn't when called from a different script

I have a script that runs a JSON Deserialization which runs perfectly. When I try to call this script from another script I keep getting an error about not being able to deserialize the current JSON object.

Now I have had issues similar to this before where the project.json files didn’t have the same dependencies but I checked that and they’re all fine.

This exact same process also ran last month with the exact same structured json strings with no issue. So I’m not sure what could have changed in a month that now causes deserialization errors when running this module from a different script. Everything is exactly the same except for the data, but the structure of the json is exactly the same as I compared a line from last month to this current feed in a JSON editor and they lined up exactly the same.

Any help on this would be greatly appreciated.

1 Like

Hey @Carl_Tannler

What is the error message you got when de-serialization failed ?

And what do you mean by script here ?

The suspect for this kind of issue is due to the improper json data received which may fail to get de-serialize as a json object.



Please check the below points

  1. You are getting everything exactly the same except for the data - Meaning you are not getting the correct data to Desterilize the JSON String into JSON Object.

  2. There is something extra or need something else in your Script that causes this exception.

  3. Refer this → Unable to start execution. Cannot deserialize current JSON object - #17)

  4. Start job, JSON deserialization error - SOLVED

1 Like

The error message I get is this:
Deserialize JSON: 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 ‘Line_no1.REVCODE’, line 1, position 357.

And I’m sorry about the terminology, I know it can be confusing. Basically I have a file that will log into a system and once it gets there it will run the assigned ‘Script’. The ‘Script’ can run on it’s own but it has to be logged into the system. So I can manually log into the system and run the Script and I don’t get this error. Everything works just fine. I only get the error when it’s being called from another process.

1 Like

Hey @Carl_Tannler

Are you using the Deserialize JSON Array ?

As I can see above in the sample JSON string its not an array, you need to use Deserialize JSON…


#4 here did the trick. The Process that calls the ‘Script’ had “Newtonsoft.Json”: “[13.0.1]” in it’s project.json. But the script could deserialize properly without that line in it’s project.json. So I took that line out of the process that calls our script and it was able to make it through. Thank you!

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