POST Data Azure Function

Yu-Wei Nicolas Tang 116 Reputation points
2021-02-09T13:55:09.46+00:00

I am using Azure Function as a POST API to post the body to an MongoDB. With the code below module.exports = async function (context, req) { await client.connect(); const database = client.db("test"); const collection = database.collection("notes"); const json = req.get await collection.insertOne(req.body) } Everything is working in debug mode, I checked with POSTman but once I send the code to deploy on Azure, the post does not work, and I get this html page? I don't understand ![65843-image.png][1] [1]: /api/attachments/65843-image.png?platform=QnA

Azure Functions
Azure Functions
An Azure service that provides an event-driven serverless compute platform.
5,908 questions
0 comments No comments
{count} votes

Accepted answer
  1. Yu-Wei Nicolas Tang 116 Reputation points
    2021-02-09T15:59:04.437+00:00

    Problem solved, it was the wrong url....

    0 comments No comments

1 additional answer

Sort by: Most helpful
  1. sadomovalex 3,636 Reputation points
    2021-02-09T15:52:57.45+00:00

    could you show what is returned in page body (1st tab in Postman response)? on your screenshot only returned headers are shown which don't tell much. When response has text/html type often page itself contains description of error

    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.