Can some one please share how to call logic apps from MVC application?

Maruthi Kiran 96 Reputation points
2020-06-13T14:26:01.997+00:00

Hi,
Can some one please share how to call logic apps from MVC application?

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

Accepted answer
  1. Maruthi Kiran 96 Reputation points
    2020-06-26T03:20:32.67+00:00

    Now i'm able to call / trigger logic app url from MVC application. And i could pass json data to logic app url . Following is my code.

    public async Task<JsonResult> Add_recordAsync(register rs)
    {

            using (var client = new HttpClient())  
            {  
                  
                var jsonData = System.Text.Json.JsonSerializer.Serialize(new  
                {  
                      
                    email = "maruthikiran@gmail.com",  
                    due = rs.Name,  
                    task = rs.Password  
                });  
                var content = new StringContent(jsonData);  
                content.Headers.ContentType.CharSet = string.Empty;  
                content.Headers.ContentType.MediaType = "application/json";  
    
                var response = await client.PostAsync("Logic App URL", content);  
    

    Reference link :https://learn.microsoft.com/en-us/azure/app-service/tutorial-send-email?tabs=dotnet#more-resources

    0 comments No comments

3 additional answers

Sort by: Most helpful
  1. Anonymous
    2020-06-13T14:31:54.193+00:00
    0 comments No comments

  2. Pramod Valavala 20,636 Reputation points Microsoft Employee
    2020-06-18T10:15:51.967+00:00

    Logic Apps run based on the trigger they have. Based on the trigger your logic apps have, how you call them will differ.

    If your Logic App uses the Request Trigger, you could simply make a REST call to the Trigger URL to call your Logic App.

    If you Logic Apps uses the Service Bus Trigger, you would want to insert a message into the corresponding queue/topic to trigger your Logic App.

    0 comments No comments

  3. Maruthi Kiran 96 Reputation points
    2020-06-24T04:04:07.507+00:00

    Hi Pramod,thanks for your response. Yes,my logic apps uses Request Trigger.Following is the code i'm using to call logic apps.it is triggering my logic apps but i cant able to pass json data as parameters to Logic app url. Please help.

     public async Task<JsonResult> Add_record(register rs)  
        {  
    
            var client = new HttpClient();  
            var jsonData = System.Text.Json.JsonSerializer.Serialize(new  
            {  
                Id = 1,  
                taskk = "My new task!",  
    
            });  
    
            HttpResponseMessage result = await client.PostAsync(  
              
            ConfigurationManager.AppSettings["Logic app URL"],  
            new StringContent(jsonData, Encoding.UTF8, "application/json"));  
             
            var statusCode = result.StatusCode.ToString();  
    

    10673-logic-app.png

    0 comments No comments

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.