Can't send data to data api

I am using mongo data api for one of my project. The issue I am facing is when I am making call to the endpoint specified in mongodb realm, it shows empty body. And when i return the body from the backend it shows me a giant buffer.

// This function is the endpoint's request handler.

exports = function({ query, headers, body}, response) {
      throw new Error("Bad Request. Body Missing");
    const {image, name, about, resume, twitter, type} = body;
    console.log("This is body")
    return body
    if(!image || !name || !about || !type){
      throw new Error("Bad Request. Required parameters are missing")
    const contentTypes = headers["Content-Type"];
    const doc ="test-buddy").db("marketleague").collection("speakers").insertOne(body)
    return  doc;

Now according to mongodb, if you want to post data, you have to send it like this

But if I show you the body it looks like this

And if I return the body directly, it shows me a giant string. You can refer to postman image.

PS: You can say I forgot to mention collection name, db name & all, but it works fine for get api as I am not using those keys anywhere. These api’s are strictly for a single database.

1 Like

Hello @Joy_Gupta ,

I responded to a similar question in below thread, please check if that works for you.