Open gjae opened 5 months ago
Hi @gjae,
Sorry for the delay.
When you receive a 400 type error, the problem does not necessarily come from the SDK (it is still possible, but quite rare).
In this scenario, you can analyze the server response that is in the HTTP error (exc.response
).
To analyze the latter, you have several options:
Via code. The idea here is to intercept HTTPError type errors to obtain the details of the latter
from requests import HTTPError
try:
response = LayoutApi(settings.NOVU_DOMAIN, settings.NOVU_API_KEY).create(new_layout)
NotificationTemplate.objects.create(
name=template_name,
local_identifier=identifier,
novu_id=response._id,
variables=json.dumps(variables)
)
except HTTPError as exc:
# Do some stuff with the error, for exemple print server response when an error 400 is returned.
if exc.response.status_code == 400:
print(exc.response.json())
raise exc
If you use Sentry, the program automatically adds an extra field called 'error_details' that you can find in your errors.
Sentry is mainly recommended for collecting and monitoring errors in Python programs. If you have other similar and Opensource collectors that you would like to integrate, do not hesitate to open an issue to request its implementation.
I'm trying creates an layout using Layout Api always returns error 400. Current implementation:
I need automate the layouts creation
Additional context I'm using django, the api key it's a environment variable