I am trying to create a C# program to call my Azure Logic app that calls a SQL Server stored procedure which grabs data from a table. I have my logic app working, I trigger it from the Azure side and it returns the data I want.
But triggering it from the code side is causing problems. I would think it would be a GET since I am getting data so I have tried
var response = await _client.GetAsync("LogicAppURL");
My function is set up as follows so I can trigger it too
[FunctionName("RunLogicApp")]
public async Task RunAsync([HttpTrigger(AuthorizationLevel.Function, "get", Route = "RunLogicApp")] HttpRequest req, ILogger log)
{
// ....
}
But Azure is failing coming back and saying that it is expecting a POST to run this Logic App. So I tried a PostAsync
and I can only get a response code of 200 back.
Which side do I need to fix, C# code or Logic App?
My stored procedure is just a select id, email, value from table
3
Answers
Logic App HTTP Triggers require the POST verb. You will also likely need a SAS token, which you can get by clicking on the trigger in the Logic App. This is tacked on to the URL as a sig query parameter.
https://yourlogicappuri/yourapp?sig=xxxxxxxxxxxxxxxxxx
To get data from Logic app by calling from c# code, follow below procedure:
Design of Logic App:
Then the
c# code
:Output:
Logic app(Code called Logic app and logic app returned response):
I hope this solution will give you with a very mimimal chnage to you existing implementation. A somple change needs to done in the Logic App to address this issue I guess.
When you add a Http Request as default trigger using Old Logic App Designer the request verb will be POST by default but don’t know that this can be chnaged.
You can change this to GET method by doing the following in OLD Logic App Designer
Select All new Parameter in the Logic App Http Action
Select GET verb in the combobox and save it
Now your Logic App default method will be GET.
When you run this logic app and go to Run-history you will see it has used GET verb