Azure Logic Apps-The template language function ‘json’ parameter is not valid.

This is a follow up from my original blog post Azure Logic Apps–Parsing JSON message from service bus

If you see the following error from a Logic App using Service Bus trigger:

{"code":"InvalidTemplate","message":"Unable to process template language expressions in action 'Next_action' inputs at line '1' and column '11': 'The template language function 'json' parameter is not valid. The provided value 'eydlbWFpbCcgOiAndGVzdEB0ZXN0LmNvbSd9' cannot be parsed: 'Unexpected character encountered while parsing value: e. Path '', line 0, position 0.'. Please see https://aka.ms/logicexpressions#json for usage details.'."}

It’s because messages that from service bus topic triggers are now presented as base 64 encoded messages rather than plain text.  Fortunately the fix is straightforward, Logic Apps give you a decodeBase64 function that you can use in the Logic App. 

You need to switch the Logic App to to code view, and use the decodeBase64 function before parsing the json.  So

image

becomes (note the call to decodeBase64 before the call to json):

image

2 Replies to “Azure Logic Apps-The template language function ‘json’ parameter is not valid.”

  1. Hi James Thanks for the post. even after using decodeBase64 I was getting "Unable to process template language expressions " error as the service bus trigger was adding additional strings like "@\u0006string\b3http://schemas.microsoft.com/2003/10/Serialization/??{" to the content. I had to use a long winded way for removing the additional strings @{json(substring(replace(decodeBase64(triggerBody()['ContentData']),'@string3http://schemas.microsoft.com/2003/10/Serialization/??', ''),0,sub(length(replace(decodeBase64(triggerBody()['ContentData']),'@string3http://schemas.microsoft.com/2003/10/Serialization/??', '')),1))).fieldname} is there a better way to do this Regards Sriram

  2. 256120 764018As I website possessor I believe the content material here is rattling great , appreciate it for your efforts. You should keep it up forever! Good Luck. 19323

Leave a Reply

Your email address will not be published. Required fields are marked *