0
votes

I am having Azure SQL database and I want to perform Insert,Update,Delete Operations by using Logic Apps and is it necessary to have a gateway while Connecting to Azure SQL DB to Sqlserver Connector in Logic -app I have Three properties 1)Id 2)Name 3)Department in 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

In sql Connector it showing Bad request: Insert -row Connector

The Body element of properties are null

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

The Output of Insert Row Connector {

"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"
}

}

Note:I am not using any gate-way please guide me on the above task if you have any resource please let me know

Logic App-Defination: Designer

previous error history: error:

data I am Passing in Payload schema: enter image description here

1
What data are you passing to the http trigger?? To me the error message is pretty clear, you are trying to insert a null value in the column which does not allow nulls in it.Mandar Dharmadhikari
I am passing the data in payload schema in http request but still its showing null values in the bodyKarthik Kasula
data-gateway need to be connected ? while passing the dataKarthik Kasula
For azure sql database, gateway is not needed. Please share following 1) Logic APP definition 2) Sample request that you sent 3) Run History from your logic app The reason I ask, is that it seems to be straight forward what you are doing. By the way you do not need to pass the header in the body of the triggerMandar Dharmadhikari
I added three pics and the error data I already Submitted in the CodeKarthik Kasula

1 Answers

1
votes

The error is occurring because you are running the trigger from the azure portal. See when I run the trigger as shown in the image below, Triggering the HTTP Function from Azure portal> Error And I encounter following error "Microsoft SQL: Cannot insert the value NULL into column 'id', table 'librarymanagement.dbo.DepartmentTable'; column does not allow nulls. INSERT fails."

To properly invoke the HTTP trigger Logic APP, you need to make a HTTP API call to it. If you are just learning, you can use POSTMAN to make the call. Following are the steps you need to do

  1. Copy the Logic APP url from the portal. Copy HTTP URL

  2. Create a new request in postman and select POST method and paste the url copied in step 1. Also paste the body as shown. Set Body

  3. Now move to Headers and Set the values as shown below. Set Headers

  4. Click on Send