Skip to content

What is the proper way to add parameters to a transactional mail sent using a template? #2

@stevesobol

Description

@stevesobol

This is part of a method I wrote to send a transactional email using a template. The signature for setParams specifies that you pass a java.lang.Object - I've tried passing manually-constructed JSON strings (as in the example below), and passing an array of brevo.Pair objects, but no mater what, I get an HTTP 400 response with a message "invalid params".

The documentation is far from clear on how to pass parameters using the Java API.

Thanks
--Steve

     TransactionalEmailsApi apiInstance = new TransactionalEmailsApi();
        SendSmtpEmail email = new SendSmtpEmail(); // SendSmtpEmail | Values to send a transactional email

        email.setSubject(subject);
        email.setTemplateId(templateId);
        email.setSender(sender);
        email.addToItem(recipient);

        email.setParams("{confirmationURL: \"https://example.com\"}");

        System.out.println(email);
        BrevoApiResponse response = null;

        try {
            CreateSmtpEmail result = apiInstance.sendTransacEmail(email);
            response = new BrevoApiResponse(result.getMessageId());
        } catch (ApiException exc ) {
            System.err.println("Exception when sending email");
            System.err.println(exc.getClass().getName());
            System.err.println(BrevoUtils.getMessageFromException(exc));
        }

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions