This repository was archived by the owner on Apr 24, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 30
LayoutApi alway returns HTTP error 400Β #244
Copy link
Copy link
Open
Description
I'm trying creates an layout using Layout Api always returns error 400.
Current implementation:
body = "html readed from a file, contains {{{body}}}"
variables = [
{"type": "String", "name": "first_name", "required": False, "defValue": ""},
{"type": "String", "name": "lastname", "required": False, "defValue": ""},
{"type": "String", "name": "email", "required": False, "defValue": ""},
{"type": "String", "name": "cellphone", "required": False, "defValue": ""},
{"type": "String", "name": "url", "required": False, "defValue": ""},
{"type": "String", "name": "path", "required": False, "defValue": ""},
{"type": "String", "name": "uuid", "required": False, "defValue": ""},
{"type": "String", "name": "id", "required": False, "defValue": ""},
{"type": "String", "name": "instagram", "required": False, "defValue": ""},
{"type": "String", "name": "facebook", "required": False, "defValue": ""},
]
variables_dto = []
for variable in variables:
variables_dto.append(LayoutVariableDto(
name=variable["name"],
type=TemplateVariableTypeEnum.STRING,
))
new_layout = LayoutDto(
name=template_name,
description="mail templates",
content=body,
is_default=False,
variables=variables_dto,
)
response = None
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 Exception as e:
print(response, e)
raise eI need automate the layouts creation
- Novu version: last version (using api.novu.co)
- Python version: 3.10.13
- Novu-python version: 1.14.0
Additional context
I'm using django, the api key it's a environment variable
Metadata
Metadata
Assignees
Labels
No labels