简体   繁体   中英

Azure Logic Apps - invalid json parameter error

Update: the problem was with the file encoding. See answer.

I've got a json payload that is 15.7 MB coming from blob storage. When I pass the output to a ParseJson action I use the json() converter function, but I get this error:

Unable to process template language expressions in action 'Parse_JSON' inputs at line '1' and column '2792': 'The template language function 'json' parameter is not valid.

Then I took the same json file and stripped it down to 1 KB and tested with the same Logic App and it worked. So is there a size limit for json()?

The problem was that the stream was written with a byte order mark (BOM) added at the start of the text, so it was not recognized as valid JSON. StreamWriter was used to write to the stream with UTF8 encoding. The fix was to not specify the encoding in the constructor, which defaults to an instance of UTF8 without a BOM:

https://docs.microsoft.com/en-us/dotnet/api/system.io.streamwriter?view=netframework-4.7.2#remarks

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM