POST request to deployed netlify function hangs with 404. Works with netlify dev server

Hello community!
Super pumped to get started with a new app on Netlify however I seem to be stuck when attempting to send a POST request to a deployed Netlify function. In an effort to ensure it was not my custom function code causing the issue I deployed the sample function code below copied from the Netlify docs.

UPDATE. I had originally left out in the body that this function does work when running from the local netlify dev server.

The deployed function can be found here:

https://gangwaze.netlify.app/.netlify/functions/dummy

GET requests to that function consistently work and the stranger thing, when testing with ThunderClient from VSCode, the POST request sporadically works when following a GET request.

import { Handler } from "@netlify/functions";

const handler: Handler = async (event) => {
  return {
    statusCode: 200,
    body: `method: ${event.httpMethod}`,
  };
};

export { handler };

Any guidance here would be much appreciated. In the meantime I shall continue to scour the forums as this feel like i’m missing something obvious here.

Cheers!
Joe

UPDATE:
Things appear to be working for me now and my suspicion is the empty request body (shown in my ThunderClient screen shot above).

I had suspected this earlier however the sporadic success was confusing me. I was getting success 202 sporadically with an empty request body and sometimes 404s with {} as the request body.

Sending {} as POST request body is working consistently for me now.

1 Like

Weird to hear - I wouldn’t expect we’d ever return an HTTP 202! If you see it again, I’d love to find out the x-nf-request-id of that response so I could look at it a bit more closely in our internal logs:

Apologies, but I wasn’t quite sure if you had managed to get this working well enough for your purposes or if you still needed debugging help?

@fool thanks for the followup. Yes I am out of the woods with my original issue and it’s full steam ahead again! I’m working under the theory still that it was my empty POST body on those requests to my function that were causing the problem.

The 202 response code was a typo I meant to say 200.

Thanks again and keep up the great work!

1 Like