I think this question is outside the FF frontend but somebody did the integration between Supabase and extrernal system.
1. How to use extension http to call POST requests with headers (jwt token in headers) right?
I think the problem is in the headers.
2. Could you get an example with POST requests with headers and Authorization?
First I test POST requests to another Supabase project as external system. But I get a 401 error (invalid API Key).
Supabase extension http - POST requests
I called API in Postman. It works. I got 201 response.
curl -X POST 'https://hfjykeknmooymayncknw.supabase.co/rest/v1/api_incomings' \
-H "Content-Type: application/json" \
-H "Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6ImhmanlrZWtubW9veW1heW5ja253Iiwicm9sZSI6ImFub24iLCJpYXQiOjE3MTIxNDkyMDUsImV4cCI6MjAyNzcyNTIwNX0.mbVHRg_0YAbvjcWL0WhKFWaeweKK6rTcPIIgdpvKgU8" \
-H "apikey: eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6ImhmanlrZWtubW9veW1heW5ja253Iiwicm9sZSI6ImFub24iLCJpYXQiOjE3MTIxNDkyMDUsImV4cCI6MjAyNzcyNTIwNX0.mbVHRg_0YAbvjcWL0WhKFWaeweKK6rTcPIIgdpvKgU8" \
-H "Prefer: return=minimal" \
-d '{"name":"test6"}'
I executed SQL query in Supabase. I got 401 error (invalid API Key).
SELECT content
FROM http((
'POST',
'https://hfjykeknmooymayncknw.supabase.co/rest/v1/api_incomings',
ARRAY[
http_header('apikey', 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6ImhmanlrZWtubW9veW1heW5ja253Iiwicm9zZSI6ImFub24iLCJpYXQiOjE3MTIxNDkyMDUsImV4cCI6MjAyNzcyNTIwNX0.mbVHRg_0YAbvjcWL0WhKFWaeweKK6rTcPIIgdpvKgU8'),
http_header('Authorization', 'Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6ImhmanlrZWtubW9veW1heW5ja253Iiwicm9zZSI6ImFub24iLCJpYXQiOjE3MTIxNDkyMDUsImV4cCI6MjAyNzcyNTIwNX0.mbVHRg_0YAbvjcWL0WhKFWaeweKK6rTcPIIgdpvKgU8')
],
'application/json', -- Указываем тип контента
jsonb_build_object('name', 'test8')::text -- Указываем тело запроса в формате JSON
) :: http_request);
I think the problem is inARRAY[
http_header('apikey', 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVC......
Also I tried function http_post. 401 error.
I checked logs in Supabase. I can't find in it what problem was.