© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
SupabaseS
Supabase•14mo ago•
5 replies
jonas.halbstark

Trigger http request to make a post request in loops

Hi All,
im trying to send all my signups to our email marketing tool loops. I hav created a function and a trigger. But the data is not landing in loops 😦
any idea why?

Here is the function:
DECLARE
  response TEXT;  -- Use TEXT instead of JSONB
  payload JSON;   -- Variable to hold the JSON payload
BEGIN
  RAISE NOTICE 'Payload to Loops API:';

  -- Construct the JSON payload
  payload := json_build_object(
    'email', NEW.email
  );

  -- Log the payload being sent
  RAISE NOTICE 'Payload to Loops API: %', payload;

  BEGIN
    -- Send HTTP request
    SELECT content INTO response
    FROM http(('POST', 'https://app.loops.so/api/v1/contacts/create', ARRAY[http_header('Authorization', 'Bearer <api key>')], 'application/json',payload::text)::extensions.http_request);

    -- Log the response received
    RAISE NOTICE 'Response from Loops.so: %', response;

  EXCEPTION 
    WHEN OTHERS THEN
      RAISE NOTICE 'Failed to send data to Loops.so: %', SQLERRM;
  END;

  RETURN response;
END;
DECLARE
  response TEXT;  -- Use TEXT instead of JSONB
  payload JSON;   -- Variable to hold the JSON payload
BEGIN
  RAISE NOTICE 'Payload to Loops API:';

  -- Construct the JSON payload
  payload := json_build_object(
    'email', NEW.email
  );

  -- Log the payload being sent
  RAISE NOTICE 'Payload to Loops API: %', payload;

  BEGIN
    -- Send HTTP request
    SELECT content INTO response
    FROM http(('POST', 'https://app.loops.so/api/v1/contacts/create', ARRAY[http_header('Authorization', 'Bearer <api key>')], 'application/json',payload::text)::extensions.http_request);

    -- Log the response received
    RAISE NOTICE 'Response from Loops.so: %', response;

  EXCEPTION 
    WHEN OTHERS THEN
      RAISE NOTICE 'Failed to send data to Loops.so: %', SQLERRM;
  END;

  RETURN response;
END;


And here the trigger (image)

Looking forward to any help 🙂
Bildschirmfoto_2025-01-10_um_23.20.49.png
Supabase banner
SupabaseJoin
Supabase gives you the tools, documentation, and community that makes managing databases, authentication, and backend infrastructure a lot less overwhelming.
45,816Members
Resources

Similar Threads

Was this page helpful?
Recent Announcements

Similar Threads

net.http_post permission denied in trigger
SupabaseSSupabase / help-and-questions
4y ago
public.http_request() Function Not Found by Trigger
SupabaseSSupabase / help-and-questions
7mo ago
Add Authorization Header to http_post
SupabaseSSupabase / help-and-questions
4y ago
pg_net http post request fails with numeric IP address
SupabaseSSupabase / help-and-questions
2w ago