Issues with sending emails via API

Your software
My Mautic version is: 3.2.2
My PHP version is: 7.4
My Database type and version is: 8.0.18

Your problem
I’m trying to use the API to create an email and schedule it to send and most things are working except two. For now, I’m just using Postman to do this so I can get the structure right before coding it into the system that will be generating the email contents. There are two fields, however, that I just cannot get to work, these are isPublished and category.

isPublished is a boolean, so I’ve tried true and 1 but the field is always set to false in the response and when viewed in the Mautic interface.

category says its type is “object” and I’ve tried passing all manner of things in that field, but the only thing I’ve found that partially works is to set the key to category[] as you do for an array and whilst this then sets a category, it always sets it to the value of category ID 1. I’ve tried category[0]['id'] and category['id'] as well, with the value set to other valid ID’s, e.g. 3, 4, 5, etc… but it always just sets it to 1.

Can someone please point me in the right direction or maybe to a guide as to how the API excepts none string values to be passed (I only found out about the array one from another forum post about the lists value). I’m thinking it might be a PHP specific thing as I’m not all that familiar with PHP and Mautic is build on PHP, so I guess it is how PHP expects the values to be passed in the POST data.

Thanks.

Andrew.

I’ve managed to work out one of these, which appears to be a bug in Mautic. The user role I created only had permission to “Publish Own”, however, to get isPublished to be accepted as 1 (true) I had to add the permission “Publish Others” to the role. As it is all done in one call, it is the users own email they are publishing, so surely “Publish Own” should be enough permission.

Still no joy with the category.

Have another issue now with the utmTags fields, which are not even in the documentation for emails but can be set in the interface and are returned in the API when you create an email as:

        "utmTags": {
            "utmSource": null,
            "utmMedium": null,
            "utmCampaign": null,
            "utmContent": null
        },

But there seems to be no way to set them via the API. Sending them with the key name like utmTags['utmSource'] returns an error:

{
    "errors": [
        {
            "code": 400,
            "message": "utmTags: This form should not contain extra fields.",
            "details": {
                "utmTags": [
                    "This form should not contain extra fields."
                ]
            }
        }
    ]
}

and sending with the key name like utmTags->utmSource they are just ignored, so similar to the category issue above.

Has anyone got any insight on this?