calling a logic-app from azure function

braxx 461 Reputation points
2021-01-18T16:40:47.163+00:00

Trying to send http request from azure function to logic app. Function in Javascript runs without error but the logic app has never been triggered. Here is how i am fetching the endpoint.

 const fetch = require("node-fetch");

    fetch("https://prod-30.eastus2.logic.azure.com:443/workflows/123axc/triggers/manual/paths/invoke?api-version=2016-10-01&sp=%2Ftriggers%2Fmanual%2Frun&sv=1.0&sig=abc123-XKP-fPs",{method: "POST", body: {"html": html}, headers: {
        "Content-Type": "application/json",
      }})

Can someone explain what is wrong or missing here?

Azure Functions
Azure Functions

An Azure service that provides an event-driven serverless compute platform.

0 comments No comments

Answer accepted by question author
MayankBargali-MSFT 71,021 Reputation points Moderator
2021-01-19T04:59:22.633+00:00

Hi @braxx

I believe html is the object that you have defined in your function and I see that you have not used JSON.stringify to convert it to json object.

fetch("https://prod-30.eastus2.logic.azure.com:443/workflows/123axc/triggers/manual/paths/invoke?api-version=2016-10-01&sp=%2Ftriggers%2Fmanual%2Frun&sv=1.0&sig=abc123-XKP-fPs",{method: "POST", body: {"html": html}, headers: {
"Content-Type": "application/json",
}})

I have tested the scenario at my end and it is working as expected. I will also suggest you to verify whether you have selected "POST" method in the drop down of "When a HTTP request is received" trigger which would cause this issue.

    let data = {  
        userId: 123,  
        title: "loren impsum doloris",  
        completed: false  
    };  
      
    fetch("https://prod-29.westus.logic.azure.com:443/workflows/yourworkflow/triggers/manual/paths/invoke?api-version=2016-10-01&sp=%2Ftriggers%2Fmanual%2Frun&sv=1.0&sig=_tPma_SSYXNpIe9Eh96Zb_7uoDw0fyfoDofxyJrCBqw", {  
        method: "POST",   
        body: JSON.stringify(data),   
        headers: { "Content-Type": "application/json"}  
      })  

You can refer to node-fetch document for more details. You will only see the error/exception if the fetch statement throws the exception. If I pass the wrong syntax in fetch statement then it throws the exception but if I do not convert the object to json then it doesn't throw any exception as you have observed.

Please 'Accept as answer' and ‘Upvote’ if it helped so that it can help others in the community looking for help on similar topics.

Was this answer helpful?


0 additional answers

Sort by: Most helpful

Your answer

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