POST request for background functions has no payload in event body property

When sending a POST request to a background function with e.g. json payload in body, the event.body property is empty.

Doing the same request as GET, the payload is available in event.body property.

This behavior is happening on live site and also via “netflify dev”.

Regards
Thorsten

Hi @Werzahltmehr.de

Can you provide the URL for where this is happening on a live site?

Are you able to provide the code from the background function?

Url of background function: https://beta.werzahltmehr.de/.netlify/functions/test-background

Code:

import { builder, Handler } from '@netlify/functions'

const myHandler: Handler = (event) => {
  console.log(event)

  return {
    statusCode: 202,
  }
}

const handler = builder(myHandler)

export { handler }

Problem is, that payload in body for GET requests is actually not supported by many clients like axios, etc.

Also, why should POST-Request work with normal functions but not with background functions?
It makes absolutely sense to send data to a background function to control the behavior of the function.

Hey @Werzahltmehr.de,

You’re talking about background functions, but you’re using builder functions. These are 2 different things. Builder functions don’t support POST requests as mentioned in the docs. Background functions do support POST requests.

1 Like