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

Campaign create with plain_text Field throws wrong error #21

Open
christian-heiko opened this issue Mar 7, 2024 · 0 comments
Open

Campaign create with plain_text Field throws wrong error #21

christian-heiko opened this issue Mar 7, 2024 · 0 comments

Comments

@christian-heiko
Copy link

christian-heiko commented Mar 7, 2024

Summary

When i set the plain_text Field on the emails array on create campaign the API returns a error and it returns a wrong one.
It says «The emails.0 field must be an array» alltough everything is set as in the API docs.

Expected Results

Both examples should work fine or return a correct error.

Actual Results

The API returns following error: «The emails.0 field must be an array»

Steps to Reproduce

<?php

use MailerLite\MailerLite;

require_once "vendor/autoload.php";

$mailerLite = new MailerLite([
    "api_key" => "",
]);

// This request works as expected:
$response = $mailerLite->campaigns->create([
    "type" => "regular",
    "name" => "My new campaign",
    "language_id" => 10,
    "emails" => [
        [
            "subject" => "My new email",
            "from_name" => "My Customer",
            "from" => "email@mycustomer.com",
            "content" => "Hello World!",
        ],
    ],
    "filter" => [],
]);

// This request throws the error that emails.0 is not set, alltough the problem is with plain_text:
$response = $mailerLite->campaigns->create([
    "type" => "regular",
    "name" => "My new campaign",
    "language_id" => 10,
    "emails" => [
        [
            "subject" => "My new email",
            "from_name" => "My Customer",
            "from" => "email@mycustomer.com",
            "content" => "Hello World!",
            "plain_text" => "Hello World!",
        ],
    ],
    "filter" => [],
]);
// PHP Fatal error:  Uncaught MailerLite\Exceptions\MailerLiteValidationException: The emails.0 field must be an array
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