Get company with "&" in name

Hi,

I am trying to get a specific company which has an ampersand in its name. The reqeust is being sent with mautic api-library to the companies endpoint with a custom query which looks something like this:

$qb = new QueryBuilder();
$qb->setSelect(“SELECT * FROM companies”);
$qb->addWhere($qb->expr()->eq(‘companyname’, “MY COMPANY & NAME”));

This works as intended as long as there is no ampsersand in the company name. The URL for the query gets encoded like this but does not return any matches even though it should:

select=SELECT+%2A+FROM+companies&where%5B0%5D%5Bcol%5D=companyname&where%5B0%5D%5Bexpr%5D=eq&where%5B0%5D%5Bval%5D=MY+COMPANY+%26+NAME&limit=1000000000000000000

Is there any way to find a company with “&” in its name?

Hi,
This issue seems to be still present, did you find any solution? Thanks!

Can you post a complete code you are using to interact with mautic api? Thanks.
Regards, M.

Hello,
I am using curl.
First, I replace spaces with %20 in the name of the company.
I also tried to replace & with %26, but with no success. As long as the name doesn’t contain “&” it works perfectly.

Below is the URL:

$reqUrlCompany = “https://” . $loginname . “:” . $password . “@” . $siteurl . “/api/companies?where%5B0%5D%5Bcol%5D=companyname&where%5B0%5D%5Bexpr%5D=eq&where%5B0%5D%5Bval%5D=” . $companyname;

Where in the docs do you see, you can pass queryBuilder as param in url.

Also there are functions to encode url properly (in basically every programming language), you do not need to replace it manually.

Regards, M.

Mautic Developer Documentation → Advanced filtering section

Hi, I have tested this, it looks like a bug to me, can you please report it on Github?

Further more might I suggest using something like vatid to filter the results. It seems more robust way of doing this.

In any case the bug should be reported and fixed in future versions of mautic.

Regards, M.

1 Like

Hi,
Deja Vu:

and

The issue is closed, but its not solved. I have tested on Mautic 4.4.6

1 Like