Problems sending body to invoke Edge function

Hey there,
I am having trouble invoking a supabase edge function using the provided workflow action.
I tried for quite some time now, but it always gave me a bad body / bad json error.

Invoking my function in Postman works and writing a small JS that fetches from my function also works without problems.

The Supabase functions expects a JSON in the from {“email":"myemail@example.com”}

I tried all sorts of variations in the body field of the Supabase Action from a string like so '{“email":"myemail@example.com”}" over an “object” just like this: {“email":"myemail@example.com”} to using the “createObject” function and building an object.

It is NOT a Cors issue, since my JS call also worked and I just modified my edge function to expect a GET call as well and using the GET with a key:value like above it worked fine.

So now my question: What am I doing wrong? :smiley:
Is there a problem with the action or do I have to modify my code somewhere or does the body has to be formatted in a way I could not find any documentation for? Also checked the forum, but could not find anything in that regard.

Thanks in advance.

Hi @Nils

Are you passing ‘{ “email”: “myemail@example.com” }’ instead of { “email”: “myemail@example.com” }
? Can you check your logs in Supabase?

Hi @DanielL ,
thanks for the fast reply.
I tried both, but none of it worked.
My logs in Supabase say that no body at all or a malformed body is sent.

Can you test with the Rest API plugin?

I think I ran into the same thing earlier (don’t quite remember). It sounds odd, but can you try to switch to JavaScript instead of formula and manually put:

return {
“email”: “myemail@email.com
}

1 Like

Hey thanks for your replies.

@DanielL I tested with the Rest API Plugin and it works with a post request and a body like this “{“email":"abc@abc.com”}” (just in my easy javascript fetch example from my first post).

@Kawwl
Thanks for the tip, but unfortunately this one also does not work. Before I tried already, but I forogt the “return”, for the JS statement. However that did not make the difference unfortunately.

So I think it has to do something with the Supabase Function invocation Action in Post mode not being able to correctly transmit my body content.

Thanks for the suggestion @Kawwl!

@Nils if it works with the REST API plugin, then there is probably something off with the plugin. If you have time, please create a ticket here with your editor link and the steps to reproduce the issue for us to check if it’s a bug: https://support.weweb.io/

It’s pretty hard for anyone to give advice any further than what’s been given without any pictures of what you’re doing and/or code snippets. In fact I’ll change that it’s impossible for anyone to help any further, everyone’s only guessing even now what the issue is. Pictures and code snippets make a huge difference to how much help people can give.

Hi all and @DanielL I have the same issue and the body received on supabase side is empty. I think something is wrong with the pluggin Invoke an Edge function. I’m doing a console.log(‘Received request1:’, await req.text()); Here is the request received with a console.log(‘Received request1:’, req);

Received request1: Request {
bodyUsed: false,
headers: Headers {
accept: “/”,
“accept-encoding”: “gzip”,
“accept-language”: “fr-FR,fr;q=0.9,en-US;q=0.8,en;q=0.7”,
apikey: “",
authorization: “Bearer xxx”,
“cdn-loop”: “cloudflare; loops=1; subreqs=1”,
“cf-connecting-ip”: "
”,
“cf-ew-via”: “15”,
“cf-ray”: “-MRS",
“cf-visitor”: ‘{“scheme”:“https”}’,
“cf-worker”: “supabase.co”,
“content-length”: “0”,
“content-type”: “application/json”,
host: “edge-runtime.supabase.com”,
origin: “https://editor.weweb.io”,
priority: “u=1, i”,
referer: “https://editor.weweb.io/”,
“sec-ch-ua”: ‘“Chromium”;v=“136”, “Google Chrome”;v=“136”, “Not.A/Brand”;v=“99”’,
“sec-ch-ua-mobile”: “?0”,
“sec-ch-ua-platform”: ‘“Windows”’,
“sec-fetch-dest”: “empty”,
“sec-fetch-mode”: “cors”,
“sec-fetch-site”: “cross-site”,
“user-agent”: “Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/136.0.0.0 Safari/537.36”,
“x-amzn-trace-id”: "Root=
”,
“x-client-info”: “supabase-js-web/2.43.5”,
“x-forwarded-for”: “**”,
“x-forwarded-port”: “443”,
“x-forwarded-proto”: “https”
},
method: “POST”,
redirect: “follow”,
url: “http://xxxx.supabase.co/create-stripe-checkout-session
}


I will try to call my edge function with javascript in a custom javascript function.

1 Like

Hi all,

I got the same matter here. Added cors parameters, tried to send body in all ways (as a formula, a jascript function, or text in body -as in the printscreen), and on supabase side body is always empty.
I have more clues on how to solve it. Here are some printscreen if it can helps.

Thanks.