Skip to content

400 Bad Request: listIds should be type array #19

Description

@chesio

I'm using EXT:brevo without DOI and got a problem with submission via Brevo API.

[ERROR] request="d0a6953ee7bc8" component="StudioMitte.Brevo.Finishers.BrevoFinisher": [400] Client error: `POST https://api.brevo.com/v3/contacts` resulted in a `400 Bad Request` response:
{"code":"invalid_parameter","message":"listIds should be type array"}

Turns out that listIds property of CreateContact must be a list, but in my case EXT:brevo sets the property as following array (list ID is set as finisher option in form.yaml):

[1 => 107]

This is an array, but not a list. I think the reason is that I have no defaultListIds set in extension configuration and the following code in Configuration.php produces an empty array that has internal key pointer set to 1:

$this->defaultListIds = GeneralUtility::intExplode(',', $settings['defaultListIds'] ?? '', true);

Behind the scenes the following happens:

php > $listIds = explode(',', '');
php > var_dump($listIds);
array(1) {
  [0]=>
  string(0) ""
}
php > unset($listIds[0]); // GeneralUtility::intExplode(..., $removeEmptyValues = true)
php > $listIds[] = 107; // Add list id from form.yaml
php > var_dump($listIds);
array(1) {
  [1]=>
  int(107)
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    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