Pass null value to execute sql query action in Logic Apps returns error

Kazi 1 Reputation point
2020-06-13T17:29:10.87+00:00

I created a test action to make it clear what is my problem, of course my original logic app is much more complicated. The execute sql query action below returns the following error. Imo this is a SQL connector bug, because it should convert json null value to corresponding DBNull value (see this for example: https://stackoverflow.com/a/26242939).

Is it possible to fix this bug?

The error message:

{  
  "error": {  
    "code": 502,  
    "source": "logic-apis-westeurope.azure-apim.net",  
    "clientRequestId": "e7b89909-3d96-46f2-83a6-695523e7b1a5",  
    "message": "BadGateway",  
    "innerError": {  
      "status": 502,  
      "message": "The parameterized query '(@Param2 nvarchar(4000))select @Param2' expects the parameter '@Param2', which was not supplied.\r\nclientRequestId: e7b89909-3d96-46f2-83a6-695523e7b1a5",  
      "error": {  
        "message": "The parameterized query '(@Param2 nvarchar(4000))select @Param2' expects the parameter '@Param2', which was not supplied."  
      },  
      "source": "sql-we.azconn-we.p.azurewebsites.net"  
    }  
  }  
}  

The execute sql query action:

"TestDBNullAction": {  
    "inputs": {  
        "body": {  
            "actualParameters": {  
                "Param2": null  
            },  
            "formalParameters": {  
                "Param2": "int"  
            },  
            "query": "select @Param2"  
        },  
        "host": {  
            "connection": {  
                "name": "@parameters('$connections')['sql']['connectionId']"  
            }  
        },  
        "method": "post",  
        "path": "/v2/datasets/@{encodeURIComponent(encodeURIComponent('default'))},@{encodeURIComponent(encodeURIComponent('default'))}/query/sql"  
    },  
    "runAfter": {},  
    "type": "ApiConnection"  
},  

Thanks

Azure SQL Database
Azure Logic Apps
Azure Logic Apps
An Azure service that automates the access and use of data across clouds without writing code.
2,839 questions
0 comments No comments
{count} votes

2 answers

Sort by: Most helpful
  1. Samara Soucy - MSFT 5,051 Reputation points
    2020-06-18T22:25:40.863+00:00

    I've sent your feedback on to the product team. You can also post on User Voice for people to vote on.

    I do understand it's not the ideal solution for you, but for now the best way to handle this case will be to chain in a Function that can handle the coalesce operation.

    1 person found this answer helpful.

  2. Sekhar_o, Chandra 1 Reputation point
    2022-07-25T18:11:17.71+00:00

    Any update on this fix yet?

    0 comments No comments