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.
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?
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.
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:
@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.
@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);
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.
Hello I am also facing the same issues… The REST API works perfectly… but that is because it lets your define body parameters in ‘fields’ section…
The invoke edge function keeps not sending the body parameters correctly and I get “Encryption function error: Request body is confirmed to be empty.\n”
Has anyone tried without using any headers? Just curious.
With no headers you also have to setup a shared cors file in your edge functions and call it from there. If you haven’t got that then you’ll still need the cors headers I believe. I haven’t used cors stuff in the header calls for awhile.
Also if anyone is happy to do a screen share with me I’d be happy to try help out. Just message me to organise a time and I’ll more easily be able to try find the issue if I can see everything that’s going on. Even with the screenshots it can still be pretty hard to debug the actual the issue.
I didn’t say YOURS is a CORS issue I said do it without headers but you need to setup cors headers in an edge function shared folder to do that. But also you haven’t given any screenshots or info on your issue so its impossible to say if what you’re experiencing is a weweb issue or something you’ve done. As I said if someone were willing to allow some screen share time so I can see whats actually going on. I’m confident I could say whether it is something going wrong on your end or wewebs end. None of the information given here gives us a very good indication of what the actual issue is.