【发布时间】:2021-10-21 23:10:59
【问题描述】:
我正在创建一个 Azure 逻辑应用程序以通过电子邮件发送包含数据的 CSV 文件。当没有数据时,Send_an_email_(V2) 步骤失败,我在其输出中看到以下错误:
Parameter 'Attachment Content' cannot be null or empty.
Azure 逻辑应用中的 Send_an_email_(V2) 操作从前面的 Create_CSV_table 操作的输出中获取部分输入。它使用Create_CSV_table 输出的body 如下所示,以便为电子邮件附件构造ContentBytes:
"actions": {
"Create_CSV_table": {
"inputs": {
"format": "CSV",
"from": "@body('Parse_JSON')"
},
"runAfter": {
"Parse_JSON": [
"Succeeded"
]
},
"type": "Table"
},
"Send_an_email_(V2)": {
"inputs": {
"body": {
"Attachments": [
{
"ContentBytes": "@{base64(body('Create_CSV_table'))}",
"Name": "report.csv"
}
],
"Body": "<p></p>",
"Subject": "My Report",
"To": "me@email.com"
},
"host": {
"connection": {
"name": "@parameters('$connections')['office365']['connectionId']"
}
},
"method": "post",
"path": "/v2/Mail"
},
"runAfter": {
"Create_CSV_table": [
"Succeeded"
]
},
"type": "ApiConnection"
}
当Create_CSV_table 步骤没有数据输入时,Create_CSV_table 步骤成功,Create_CSV_table 步骤的原始输出显示空正文如下:
{
"body": ""
}
失败的 Send_an_email_(V2) 步骤的原始输入
{
HTTP stuff ...,
"body": {
"Attachments": [
{
"ContentBytes": "",
"Name": "report.csv"
}
],
"Body": "<p></p>",
"Subject": "Report",
"To": "me@mail.com"
}
}
失败的 Send_an_email_(V2) 步骤的原始输出
{
HTTP stuff ...,
"body": {
"status": 400,
"message": "Parameter 'Attachment Content' cannot be null or empty.\r\nclientRequestId: 887e3968-c7e9-4c35-b588-f76fd0e51545",
"error": {
"message": "Parameter 'Attachment Content' cannot be null or empty."
},
"source": "office365-ase.azconn-ase.p.azurewebsites.net"
}
}
我该如何处理?我是否需要为Send_an_email_(V2) 输入的"ContentBytes" 实现自己的空处理?如果是这样,我该怎么做?或者有没有其他方法来处理这个问题。我希望在没有 CSV 内容时发送空电子邮件。
我发现 @{base64(body('Create_CSV_table'))} 是一个 Azure 逻辑应用程序 expression(由 @ 表示),其中包含作用于 body 的 JSON 的函数,用于 Create_CSV_table 的输出以及封闭的 @ 987654341@ 导致表达式的输出为字符串。
【问题讨论】:
-
这是因为
Send an Email (V2)连接器i.imgur.com/fMs8MDb.png的附件内容中没有添加任何内容 -
嗨@SwethaKandikonda-MT 这不是问题。我已经在问题中详细解释了这个问题;)
标签: azure-logic-apps