Mautic Community Forums

No way to clear MultiSelect field via API

Your software
My Mautic version is: v3.3.3
My PHP version is: 7.4.9
My Database type and version is: mysqlnd 7.4.9

Your problem
Unable to clear MultiSelect field for contact via API.

Prerequisites:

  1. Custom field with name ‘MultiSelectList’ (alias multiselectlist) and type ‘Select - Multiple’. Available values for list are ‘v1’, ‘v2’ and ‘v3’.
  2. Contact created with ID, for example, 215.
  3. Assume Contact with ID 215 has MultiSelectList value “v1”

Steps to reproduce:
Send authorized PATCH request to ‘https://{{host}}/api/contacts/215/edit’ with payload:

{
    "multiselectlist": null
}

Actual result
Server returns error in response:

{
    "errors": [
        {
            "code": 400,
            "message": "multiselectlist: This value is not valid.",
            "details": {
                "multiselectlist": [
                    "This value is not valid."
                ]
            }
        }
    ]
}

Expected result
Server returns Contact JSON, MultiSelectList field has ‘null’ (no selected) value.

Steps I have tried to fix the problem:

I tried to send different values for ‘multiselectlist’: null, (empty array), “” (empty string), false, 0 (zero).

Please, clarify how to clear MultiSelect fields via API.