# Rest API in Mautic 5 delivers empty result array but no error

**URL:** https://forum.mautic.org/t/rest-api-in-mautic-5-delivers-empty-result-array-but-no-error/30596
**Category:** Development
**Created:** [January 21, 2024, 7:55pm UTC](https://forum.mautic.org/t/rest-api-in-mautic-5-delivers-empty-result-array-but-no-error/30596 "2024-01-21T19:55:57Z")
**Posts on this page:** 7
**Page:** 1

<div class="post-metadata">

### Author: ![mcdiver](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/mcdiver/32/6618_2.png) [@mcdiver](https://forum.mautic.org/u/mcdiver)
#### Post date: [January 21, 2024, 7:55pm UTC](https://forum.mautic.org/t/rest-api-in-mautic-5-delivers-empty-result-array-but-no-error/30596/1 "2024-01-21T19:55:57Z")

</div>

Hey Guys,

MyMautic: 5.0.2 (VPS)  
MyPHP Server: 8.1  
MyPHP local 8.2.

I am using a php script to retrieve a mail with the Rest API. The code worked fine with Mautic 4.x. However, I am trying to use it on my Mautic 5.0.2 and unfortunately all I get as result is an empty email array  
 ![image](https://us1.discourse-cdn.com/flex020/uploads/mautic/original/2X/f/ff0f93574041df1369637e8fe8fbdcc83c00cd7c.png)  
Are there known issues with the Rest API in Mautic 5? Or did I miss something, which I need to consider now in contrast to Mautic 4?

Thank you in advance for your help.

Kind regards,

---

<div class="post-metadata">

### Author: ![mzagmajster](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/mzagmajster/32/687_2.png) [@mzagmajster](https://forum.mautic.org/u/mzagmajster)
#### Post date: [January 22, 2024, 8:27am UTC](https://forum.mautic.org/t/rest-api-in-mautic-5-delivers-empty-result-array-but-no-error/30596/2 "2024-01-22T08:27:20Z")

</div>

Maybe there is no records?

What request are you issuing to the server?

---

<div class="post-metadata">

### Author: ![mcdiver](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/mcdiver/32/6618_2.png) [@mcdiver](https://forum.mautic.org/u/mcdiver)
#### Post date: [January 23, 2024, 6:22am UTC](https://forum.mautic.org/t/rest-api-in-mautic-5-delivers-empty-result-array-but-no-error/30596/3 "2024-01-23T06:22:31Z")

</div>

Yeah, that is generally a good idea to check. Unfortunately, I tried mails and users without succes, both arrays are empty even though there are some entries in the database.

Is there anybody who already uses the API with PHP in Mautic 5? (I am pretty sure, I miss something but I am confused since my code is working fine with Mautic 4 but not with Mautic 5)

---

<div class="post-metadata">

### Author: ![mzagmajster](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/mzagmajster/32/687_2.png) [@mzagmajster](https://forum.mautic.org/u/mzagmajster)
#### Post date: [January 23, 2024, 10:19am UTC](https://forum.mautic.org/t/rest-api-in-mautic-5-delivers-empty-result-array-but-no-error/30596/4 "2024-01-23T10:19:41Z")

</div>

Can you paste the exact endpoint/url you are calling and request you are sending on that endpoint?

---

<div class="post-metadata">

### Author: ![steffenabel](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/steffenabel/32/9907_2.png) [@steffenabel](https://forum.mautic.org/u/steffenabel)
#### Post date: [January 24, 2024, 8:29pm UTC](https://forum.mautic.org/t/rest-api-in-mautic-5-delivers-empty-result-array-but-no-error/30596/5 "2024-01-24T20:29:47Z")

</div>

I’m having the same issue after upgrading to Mautic 5 from Mautic 4.  
A quickfix for the moment is to disable setting of the serializer groups in Line 679 of app/bundles/ApiBundle/Controller/FetchCommonApiController.php. I just commented out this single line here. Now the returned entities are pretty large but it is a quickfix that works for me at the moment.

```auto
        if (!empty($this->serializerGroups)) {
// $context->setGroups($this->serializerGroups);
        }

```

Would highly appreciate a hint to a complete fix. I don’t understand where the relation between serializer group and fields that should be serialized is defined as I didn’t find any annotations on the entities.

---

<div class="post-metadata">

### Author: ![mzagmajster](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/mzagmajster/32/687_2.png) [@mzagmajster](https://forum.mautic.org/u/mzagmajster)
#### Post date: [January 24, 2024, 9:14pm UTC](https://forum.mautic.org/t/rest-api-in-mautic-5-delivers-empty-result-array-but-no-error/30596/6 "2024-01-24T21:14:19Z")

</div>

There is a method in Entity\Lead.php that sets groups for this serializer.

> <https://github.com/mautic/mautic/blob/3be38f31b6b5d8d8c7e1feff30dd4d388619ff70/app/bundles/LeadBundle/Entity/Lead.php#L427>

---

<div class="post-metadata">

### Author: ![steffenabel](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/steffenabel/32/9907_2.png) [@steffenabel](https://forum.mautic.org/u/steffenabel)
#### Post date: [January 24, 2024, 9:25pm UTC](https://forum.mautic.org/t/rest-api-in-mautic-5-delivers-empty-result-array-but-no-error/30596/7 "2024-01-24T21:25:32Z")

</div>

I didn’t have time to look into it further, but could the issue occur due to the missing leadBasic serializerGroup in LeadApiController?

> <https://github.com/mautic/mautic/blob/3be38f31b6b5d8d8c7e1feff30dd4d388619ff70/app/bundles/LeadBundle/Controller/Api/LeadApiController.php#L81>
