Mautic API creates lead entity with NULL values

Your software
My Mautic version is: 5.2.4
My PHP version is: 8.2.20
My Database type and version is: MariaDB 10.5.18

Your problem
Using composer-based Mautic v5.2.4 (latest) and creating contacts via Mautic API endpoint:

POST https://<mautic-local-url>/api/contacts/new
Authorization: Basic <md5_encode(username:password)>
Content-Type: application/json

{"firstname": "Alexander", "lastname": "Nitsche", "email": "alexander.nitsche@t-online.de"}

Unfortunately, the persisted entity in db table leads only contains fields of value NULL except for fields id, is_published, date_added, created_by and created_by_user. It worked some days ago, not sure, what happened. I checked for users with restricted and also admin rights.

These errors are showing in the log: None, the server sends a 201 (Created) instead.

While step debugging into LeadApiController.php::newEntityAction(), it seems to be that the API is using the controller to fill the request parameters into the lead form and send this form. It seems to be that the filling is not done right and the form fields remain empty.

In \Mautic\ApiBundle\Controller\CommonApiController::processForm() the $submitParams always contain the correct request parameters, but they never make it into $form nor $entity, where the latter gets eventually persisted in the database.

Now i become aware that the form fields like firstname etc. are missing in mautic frontend too .. huh?!

It seems that {% set groups = fields|keys|sort %} in /public/app/bundles/LeadBundle/Resources/views/Lead/form.html.twig is empty and therefore no fields are rendered ..

My lead_fields db table is empty and maybe that is the reason?

1 Like

I probably was to eager to reset the stage for testing ..

Is there a way to recreate the default entries of the lead_fields table?

John: Not without clearing also the rest of the tables.

Reinstalling mautic solved the problem, thx!

This topic was automatically closed 36 hours after the last reply. New replies are no longer allowed.