Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
stevesobol opened this issue Jan 9, 2025 · 0 comments

Comments

@stevesobol
Copy link

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));
        }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant