S
Supabase8mo ago
Othman

DB trigger can't find supabase.httpRequest() function

I have this trigger
CREATE trigger "get_conversation_detail" after insert on
"public"."interview" for each row
execute function "supabase_functions"."http_request"(
'https://dujoqwrvmrvcgliupzkd.supabase.co/functions/v1/get-conversation-details',
'POST',
'{"Content-Type":"application/json",
"Authorization":"Bearer "}',
'{"interview_id":"95fbd144-e05a-4e1b-98b5-f064d6da84c6",
"conversation_id":"EUSBkgmGyih7er3xTjn0"
}',
5000
)
CREATE trigger "get_conversation_detail" after insert on
"public"."interview" for each row
execute function "supabase_functions"."http_request"(
'https://dujoqwrvmrvcgliupzkd.supabase.co/functions/v1/get-conversation-details',
'POST',
'{"Content-Type":"application/json",
"Authorization":"Bearer "}',
'{"interview_id":"95fbd144-e05a-4e1b-98b5-f064d6da84c6",
"conversation_id":"EUSBkgmGyih7er3xTjn0"
}',
5000
)
when i run this query
`INSERT INTO public.interview (candiate_id,conversation_id,meeting_id, agent_id)
VALUES ('50616f55-86a4-4b91-8a04-b507f3f6bbab', 'lXQHtdrHqiveGaYo9kLi', 'lXQHtdrHqiveGaYo9kLi', 'lXQHtdrHqiveGaYo9kLi');
`INSERT INTO public.interview (candiate_id,conversation_id,meeting_id, agent_id)
VALUES ('50616f55-86a4-4b91-8a04-b507f3f6bbab', 'lXQHtdrHqiveGaYo9kLi', 'lXQHtdrHqiveGaYo9kLi', 'lXQHtdrHqiveGaYo9kLi');
it fails as it can't find the httpRequest method
14 Replies
Othman
OthmanOP8mo ago
ERROR: 42883: function http_request(unknown, text, text[]) does not exist
HINT: No function matches the given name and argument types. You might need to add explicit type casts.
QUERY: response := http_request(
'https://dujoqwrvmrvcgliupzkd.supabase.co/functions/v1/get-conversation-details',
'{"conversation_id": "' || NEW.conversation_id || '", "interview_id": "' || NEW.id || '"}',
ARRAY[
'Content-Type: application/json',
'Authorization: Bearer

]
)
CONTEXT: PL/pgSQL function notify_new_interview() line 7 at assignment
ERROR: 42883: function http_request(unknown, text, text[]) does not exist
HINT: No function matches the given name and argument types. You might need to add explicit type casts.
QUERY: response := http_request(
'https://dujoqwrvmrvcgliupzkd.supabase.co/functions/v1/get-conversation-details',
'{"conversation_id": "' || NEW.conversation_id || '", "interview_id": "' || NEW.id || '"}',
ARRAY[
'Content-Type: application/json',
'Authorization: Bearer

]
)
CONTEXT: PL/pgSQL function notify_new_interview() line 7 at assignment
garyaustin
garyaustin8mo ago
Did you enable webhooks? Do you have another trigger on this table calling the http extension or the function you show above? Sort of weird it is complaining about parameters not matching and you have and a url, string (with NEW in it?) and an actual array being passed. Your trigger above does not match that pattern.
Othman
OthmanOP8mo ago
@garyaustin actually, I had other triggers, and I removed them but I still get the same issue, I have attached a screenshot of the current triggers. and this is the trigger code
-- Create the trigger function
CREATE OR REPLACE FUNCTION public.trigger_get_conversation_detail()
RETURNS TRIGGER AS $$
BEGIN
-- Call the Supabase HTTP request function
PERFORM supabase_functions.http_request(
'https://dujoqwrvmrvcgliupzkd.supabase.co/functions/v1/get-conversation-details',
'POST',
'{"Content-Type":"application/json",
"Authorization":"Bearer "}',
json_build_object(
'interview_id', NEW.id,
'conversation_id', NEW.conversation_id
)::text,
5000
);

-- Return the new row
RETURN NEW;
END;
$$ LANGUAGE plpgsql;

-- Create the trigger
CREATE OR REPLACE TRIGGER get_conversation_detail
AFTER INSERT ON public.interview
FOR EACH ROW
EXECUTE FUNCTION public.trigger_get_conversation_detail();
-- Create the trigger function
CREATE OR REPLACE FUNCTION public.trigger_get_conversation_detail()
RETURNS TRIGGER AS $$
BEGIN
-- Call the Supabase HTTP request function
PERFORM supabase_functions.http_request(
'https://dujoqwrvmrvcgliupzkd.supabase.co/functions/v1/get-conversation-details',
'POST',
'{"Content-Type":"application/json",
"Authorization":"Bearer "}',
json_build_object(
'interview_id', NEW.id,
'conversation_id', NEW.conversation_id
)::text,
5000
);

-- Return the new row
RETURN NEW;
END;
$$ LANGUAGE plpgsql;

-- Create the trigger
CREATE OR REPLACE TRIGGER get_conversation_detail
AFTER INSERT ON public.interview
FOR EACH ROW
EXECUTE FUNCTION public.trigger_get_conversation_detail();
There is something strange i don't understand
No description
garyaustin
garyaustin8mo ago
What is the notify_webhook trigger? And did you enable webhooks?
Othman
OthmanOP8mo ago
webhooks are enabled, i had other simpler webhook and it was working normally
garyaustin
garyaustin8mo ago
You should go the the database/trigger UI and turn off the other trigger. Also is your error exactly the same with the "new" trigger code you are showing? I don't see an array in that either.
Othman
OthmanOP8mo ago
no it different error now
ERROR: 42883: function supabase_functions.http_request(unknown, unknown, unknown, text, integer) does not exist
HINT: No function matches the given name and argument types. You might need to add explicit type casts.
QUERY: SELECT supabase_functions.http_request(
'https://dujoqwrvmrvcgliupzkd.supabase.co/functions/v1/get-conversation-details',
'POST',
'{"Content-Type":"application/json",
"Authorization":"Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6ImR1am9xd3J2bXJ2Y2dsaXVwemtkIiwicm9zZSI6InNlcnZpY2Vfcm9sZSIsImlhdCI6MTczNjAxNjI0MSwiZXhwIjoyMDUxNTkyMjQxfQ.4A9wP4R2HyUuj34-YHissWkU_oBN_cAEtR5sVnsuvEM"}',
json_build_object(
'interview_id', NEW.id,
'conversation_id', NEW.conversation_id
)::text,
5000
)
CONTEXT: PL/pgSQL function trigger_get_conversation_detail() line 4 at PERFORM
ERROR: 42883: function supabase_functions.http_request(unknown, unknown, unknown, text, integer) does not exist
HINT: No function matches the given name and argument types. You might need to add explicit type casts.
QUERY: SELECT supabase_functions.http_request(
'https://dujoqwrvmrvcgliupzkd.supabase.co/functions/v1/get-conversation-details',
'POST',
'{"Content-Type":"application/json",
"Authorization":"Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6ImR1am9xd3J2bXJ2Y2dsaXVwemtkIiwicm9zZSI6InNlcnZpY2Vfcm9sZSIsImlhdCI6MTczNjAxNjI0MSwiZXhwIjoyMDUxNTkyMjQxfQ.4A9wP4R2HyUuj34-YHissWkU_oBN_cAEtR5sVnsuvEM"}',
json_build_object(
'interview_id', NEW.id,
'conversation_id', NEW.conversation_id
)::text,
5000
)
CONTEXT: PL/pgSQL function trigger_get_conversation_detail() line 4 at PERFORM
i am trying to delete the notify_webhook but it doesn't get deleted, and there is no web_hooks in the UI (in integration ) i don't have one created through UI but i am sure that notify_webook is not on the interview table so i don't think that it will cause problem
garyaustin
garyaustin8mo ago
Then number is also a string when calling the function. You have an integer.
Othman
OthmanOP8mo ago
yes you are correct, but this doesn't solve the issue the error message at PERFORM i don't why it fails (Btw i tried make number string) now and still getting the error the issue is most probably that i created trigger function I had a webhook that was basically taking static inverview_id and covnersiation_id and it worked fine, when I wanted to make the static data dynamic from the newly added row i had to use JSON_build_object and in order to use this i had to create a function for the trigger
garyaustin
garyaustin8mo ago
The example shows using execute.
Othman
OthmanOP8mo ago
tried to use both and it didn't work also :xd)
garyaustin
garyaustin8mo ago
Sorry, I've not used the webhook function directly. Others have got it working though.
Othman
OthmanOP8mo ago
it is okay, I really appreciate your help

Did you find this page helpful?