To execute the SQL query using a input value and fetch other columns of a table

2025-05-14T11:40:49.52+00:00

Hi Team - I am new to Azure Logic Apps. My intention is to get an input value from user and pass it in request payload to run a select statement in SQL server database table and fetch other required columns.
For Ex: I am getting input of patientgovtidnum from the user and pass this value in http request payload and in execute SQL query action, I am running a select statement to fetch other few details like patient_fullname etc.
I have created a flow for the same and configured all required information. When I tried to test my flow using test payload json parameter, it throws 400 error. Please find attached my complete code and also the error for your kind reference.
Could you please assist me to fix this error.
Azure_LogicApps_Code.txtAzure_LogicApps_Logs.txt

Azure Logic Apps
Azure Logic Apps
An Azure service that automates the access and use of data across clouds without writing code.
3,542 questions
{count} votes

1 answer

Sort by: Most helpful
  1. RithwikBojja 3,055 Reputation points Microsoft External Staff Moderator
    2025-05-16T03:40:21.61+00:00

    Hi @Sambathkumar, Vinodhkumar (Cognizant),

    I have tried below approach and it worked for me:

    Initially, I have below sql table ouput for the below query :

    SELECT sch_id, stdnt_name FROM rithadmin WHERE aad_num =  009;
    

    image

    Then created a parameter:

    stuaadnum with value 009

    enter image description here

    Now to get/reproduce your error used same design:

    enter image description here

    Error:

    enter image description here

    To solve this issue:

    Initially clicked on Dynamic values:

    enter image description here

    Then pressed on stuaadnum as below:

    enter image description here

    Now it becomes like this:

    SELECT sch_id, stdnt_name FROM rithadmin WHERE aad_num =@{parameters('stuaadnum')} 
    

    enter image description here

    Output:

    enter image description here

    Body :

    enter image description here

    This is how parameters are used in SQL query Action.


    If this answer was helpful, please click "Accept the answer" and mark Yes, as this can help other community members.

    enter image description here

    If you have any other questions or are still experiencing issues, feel free to ask in the "comments" section, and I'd be happy to help.


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.