I’m looking to see if anyone has some guidance on how to address an issue I have with some json data I’m receiving from an Http request. I am receiving a json array from a vendor and I need to loop through the array to find if it contains a specific document. This array contains all the documents attached to an account. I have deserialized the array and, using a for each, am able to look for the specific document name I need.
The issue I run into occurs when there is not an attachment to a document name. This is what it looks like when there is an attachment. If there is not the “document” section is just missing.
Here is what it looks like when the document is missing:
I have tried various IF statements and they always return a false. If I juse the SelectToken statement, I get "Value cannot be null (Parameter ‘source’).
I saw mention of using ContainsKey, but that doesn’t work as my for each argument is Newtonsoft.Json.Linq.JToken.
CurrentItem.SelectToken(“document”).Any()
String.IsNullOrEmpty(CurrentItem(“document”).ToString)
Here is a picture of my current process. Any suggestions would be greatly appreciated.
Thanks @ppr . I knew it was something I was missing as I rarely have to change the Argument type. Once I changed my For each to Newtonsoft.Json.Linq.JObject it started to work. I did notice a very odd thing through, the field names were coming across different than what I would see in Postman. In Postman, the “document” field comes across as “assignedTo”, and the “attachmentId” is “Id”. I know there may be no reason why for this but wanted to put it out there in case anyone else has odd issues like that. Always good to thrown in write lines when debugging oddities.