【问题标题】:insert row in Azuresqldatabase by using Azure Logic Apps使用 Azure 逻辑应用在 Azuresql 数据库中插入行
【发布时间】:2020-05-04 08:42:56
【问题描述】:

我有 Azure SQL 数据库,我想使用逻辑应用执行插入、更新、删除操作 是否需要网关同时连接到 Azure SQL DB 到 Logic-app 中的 Sqlserver 连接器我有三个属性 1)Id 2)名称 3)Azure SqlDB 中的部门

**When HTTP Request is Received Code:**
{
"headers": {
    "Accept": "application/json",
    "Content-Type": "application/json"
},
"properties": {
    "Department": {
        "type": "string"
    },
    "Name": {
        "type": "string"
    },
    "id": {
        "type": "integer"
    }
},
"type": "object"

} Http Request is Received

在 sql 连接器中显示错误请求: Insert -row Connector

属性的Body元素为空

{ "Department": null, "Name": null,  "id": null  }

插入行连接器的输出 {

"statusCode": 400,
"headers": {
    "Pragma": "no-cache",
    "x-ms-request-id": "3332d425-3e10-4f04-b618-63f359168acc",
    "Strict-Transport-Security": "max-age=31536000; includeSubDomains",
    "X-Content-Type-Options": "nosniff",
    "X-Frame-Options": "DENY",
    "Timing-Allow-Origin": "*",
    "x-ms-apihub-cached-response": "false",
    "Cache-Control": "no-store, no-cache",
    "Date": "Mon, 04 May 2020 08:16:24 GMT",
    "Content-Length": "468",
    "Content-Type": "application/json",
    "Expires": "-1"
},
"body": {
    "status": 400,
    "message": "Microsoft SQL: Cannot insert the value NULL into column 'id', table '.dbo.Details'; column does not allow nulls. INSERT fails.\r\nclientRequestId: 3332d425-3e10-4f04-b618-63f359168acc",
    "error": {
        "message": "Microsoft SQL: Cannot insert the value NULL into column 'id', table 'dbo.Details'; column does not allow nulls. INSERT fails."
    },
    "source": "sql-eus2.azconn-eus2.p.azurewebsites.net"
}

}

注意:我没有使用任何网关,请指导我完成上述任务如果您有任何资源,请让我 知道

逻辑应用定义: Designer

以前的错误历史: error:

我在 Payload 模式中传递的数据: enter image description here

【问题讨论】:

  • 你将什么数据传递给 http 触发器??对我来说,错误消息很清楚,您试图在不允许空值的列中插入空值。
  • 我在 http 请求中传递有效载荷模式中的数据,但它仍然在正文中显示空值
  • 需要连接数据网关?在传递数据时
  • 对于azure sql 数据库,不需要网关。请分享以下内容 1)逻辑 APP 定义 2)您发送的示例请求 3)从您的逻辑应用程序运行历史 我问的原因是,您正在做的事情似乎很简单。顺便说一句,您不需要在触发器的主体中传递标题
  • 我在代码中添加了三张图片和我已经提交的错误数据

标签: azure azure-sql-database azure-functions azure-web-app-service azure-logic-apps


【解决方案1】:

发生错误是因为您正在从 azure 门户运行触发器。看看我什么时候运行触发器,如下图所示, 我遇到以下错误 “Microsoft SQL:无法将值 NULL 插入到列 'id'、表 'librarymanagement.dbo.DepartmentTable';列不允许空值。插入失败。”

要正确调用 HTTP 触发器逻辑 APP,您需要对其进行 HTTP API 调用。如果您只是学习,可以使用 POSTMAN 拨打电话。以下是您需要执行的步骤

  1. 从门户复制逻辑 APP url。

  2. 在邮递员中创建一个新请求并选择POST方法并粘贴在步骤1中复制的url。如图所示粘贴正文。

  3. 现在移动到标题并设置如下所示的值。

  4. 点击发送

【讨论】:

  • 我尝试使用 Post Man 尝试运行我的逻辑应用程序时得到响应状态为 202 Accepted “我看到相同的错误 id 值不能为 null”
猜你喜欢
  • 1970-01-01
  • 2020-06-01
  • 2021-04-10
  • 1970-01-01
  • 2022-10-14
  • 2021-02-02
  • 2013-04-12
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多