Invoke a Supabase Function.
Blob
, ArrayBuffer
, File
, FormData
and String
. If it doesn't match any of these types we assume the payload is json
, serialise it and attach the Content-Type
header as application/json
. You can override this behaviour by passing in a Content-Type
header of your own.response = supabase.functions.invoke(
"hello-world",
invoke_options={
"body": {"name": "Functions"},
},
)
from supafunc.errors import FunctionsRelayError, FunctionsHttpError
try:
response = supabase.functions.invoke(
"hello-world",
invoke_options={
"body": {"foo": "bar"},
"headers": {"my-custom-header": "my-custom-header-value"},
},
)
except FunctionsHttpError as exception:
err = exception.to_dict()
print(f'Function returned an error {err.get("message")}')
except FunctionsRelayError as exception:
err = exception.to_dict()
print(f'Relay error: {err.get("message")}')
response = supabase.functions.invoke(
"hello-world",
invoke_options={
"headers": {
"my-custom-header": "my-custom-header-value",
},
"body": {"foo": "bar"},
},
)