Search code examples
jsonhttp-postazure-logic-appsemail-attachmentsazure-http-trigger

Logic app -send email with attachment-"Unable to parse template language expression 'base64('triggerBody()?['contentBytes']')': "


Working on sending email on http trigger with attachments in logic app. Providing json input as below

{
    "properties": {
        "bcc": {
            "type": "string"
        },
        "body": {
            "type": "string"
        },
        "cc": {
            "type": "string"
        },
        "subject": {
            "type": "string"
        },
        "to": {
            "type": "string"
        },
        "attachments":{
            "name":{
                "type":"string"
            },
            "ContentBytes":{
                "type":"string"
            }
        },
        "type":"object"
    },
    "type": "object"
}

passing attachment in base64 string format. But while configuring attachments for content variable getting an error

Unable to parse template language expression 'base64('triggerBody()?['contentBytes']')': expected token 'RightParenthesis' and actual 'Identifier'.".'

enter image description here


Solution

  • You need to click on Add dynamic content and use the following expression:

    base64(triggerBody()?['attachments']?['ContentBytes'])
    

    enter image description here