Custom Functions Serverless POST not recognizing data in production

Hey guys!

I’ve been diving into your custom functions and I’m running into a problem which I can’t seem to figure out. Request data seems to be available locally, however when I try to run the code in production and accessing through an http client (Postman), no request data seems to be seen through the events argument.

I have been able to get the function working locally with 8base invoke-local createUser -p mock/email.json
Where email.json looks like

{
  "data": {
    "email": "test@test.com"
  }
}

I was successfully able to retrieve this information from the event variable from the function arguments.

However when trying to run this command in production after deploying with a request body, the events object shows no data.
I’ve tried with a request body that looks like

{
    "email": "test@test.com"

}

as well as

{
  "data": {
    "email": "test@test.com"
  }
}

Maybe I’m overlooking something of how custom functions takes in data with an http call?

My current code for debugging currently is pretty simple

module.exports = async (event, ctx) => {
    return {
        statusCode: 200,
        body: JSON.stringify({"event": event, "ctx": ctx})
    }
};

Hey! Can you console.log the event argument and let me know what it looks like?

Sure!

{
        "data": null,
        "headers": {
            "Accept": "*/*",
            "Accept-Encoding": "gzip, deflate",
            "cache-control": "no-cache",
            "CloudFront-Forwarded-Proto": "https",
            "CloudFront-Is-Desktop-Viewer": "true",
            "CloudFront-Is-Mobile-Viewer": "false",
            "CloudFront-Is-SmartTV-Viewer": "false",
            "CloudFront-Is-Tablet-Viewer": "false",
            "CloudFront-Viewer-Country": "DE",
            "Content-Type": "application/json",
            "Host": "api.8base.com",
            "Postman-Token": "3635c413-5405-4f20-bca1-df2f9eaccb42",
            "User-Agent": "PostmanRuntime/7.1.1",
            "Via": "1.1 458f29e42261f01e7368474593f44b66.cloudfront.net (CloudFront)",
            "X-Forwarded-For": "37.120.27.58, 70.132.42.86",
            "X-Forwarded-Port": "443",
            "X-Forwarded-Proto": "https"
        },
        "body": "{ \"data\" : {\n\t\"email\" :\"test\" \n\t}\n}"
    }

I notice that the raw body is there, but I expected the data to be in the data attribute from the docs

Hey @a.ngn! Can you try parsing the body param for now? We’re looking into this…