Skip to content
This repository has been archived by the owner on Sep 26, 2024. It is now read-only.

API - List Contacts Companies - Search Parameter #158

Open
YannickBiet opened this issue Sep 1, 2017 · 28 comments
Open

API - List Contacts Companies - Search Parameter #158

YannickBiet opened this issue Sep 1, 2017 · 28 comments

Comments

@YannickBiet
Copy link

YannickBiet commented Sep 1, 2017

Q A
Bug report? No
Feature request? Yes
Enhancement? No

Description:

Currently the REST API for companies listing is not filterable !
https://developer.mautic.org/#list-contact-companies

It asks ages to get a list from Mautic that owns hundred of thousands companies !

As it is already implemented in Contacts, it would be great to have the same possibilities with Companies to have the same level of functionalities whatever we want to deal / sync contacts or companies

If a bug:

Q A
Mautic version 2.9.2
PHP version 7.0.12

Want to back this issue? Post a bounty on it! We accept bounties via Bountysource.

@escopecz
Copy link
Member

escopecz commented Sep 1, 2017

Could you please provide some examples of what's wrong and/or what your suggestions are? I don't understand it from your request.

@YannickBiet
Copy link
Author

Currently when we want to push from CRM a new contact to mautic (not existing into Mautic) and we want to send at the same time accounts' details.
We need so to retrieve the account based on the account name (for example) to identify if the account is already existing in Mautic.

Currently we must load the full Accounts list to retrieve thousands of answers to try to match our account name as we can't refine our API call with a search string like Contacts list.

Does this make sense for you ?

@escopecz
Copy link
Member

escopecz commented Sep 1, 2017

Why don't you use

GET /api/companies?search=mautic

replace mautic with the company name you are looking for

@YannickBiet
Copy link
Author

https://developer.mautic.org/#get-company

This list is not filterable.

There 's no filters available in the documentation.

TBH we used the search filter as in the Contacts list filter (with extended criterias) but it didn't work. As documentation said that the list is not filterable, we assumed that we cannot do any search.. we were (partially) wrong.

Thanks for the tip ! We will use that. Still we can keep that FR to provide:

  • either change the documentation, because the list is filterable using the search criteria to provide a name (only)
  • either extends the search to the same behaviour than for Contacts, but for Companies

@escopecz
Copy link
Member

escopecz commented Sep 1, 2017

Will you have time to update the docs? https://github.com/mautic/developer-documentation

@YannickBiet
Copy link
Author

@captivea-qch Can you help on this one ?

@npracht
Copy link
Member

npracht commented Jul 12, 2018

@captivea-ylb could you please carry that as requested by @YannickBiet ?
Thanks !

@laabidi21
Copy link

@escopecz it is possible to search for contacts according to a company (we have the company ID). and we are looking for the contact list ?

@escopecz
Copy link
Member

Should be possible to use the company search command. But it uses company name instead of ID. Is that a problem? company:"Company name"

@laabidi21
Copy link

@escopecz the problem is that the name of the company is not unique. the company ID will be more precise. is it possible to filter contacts by company ID? or the only way is to use the company name?

@escopecz
Copy link
Member

Contacts to companies relationship is stored in the companies_leads table. And you can filter this table via API as it's considered a stat table https://developer.mautic.org/#stats. But you'll work with IDs only there.

@laabidi21
Copy link

@escopecz with this method of accessing the relations table and seeing the IDs of the contacts of such a Company, will be slower to access the content of the properties of the contacts. (if in a company, I have 1000 contacts, I will then make 1000 API requests to have all the contacts with get(ID)).
a short question: if I have two companies with the same name XX, and I request them from API Call the contacts that contain this company (company:"XX"); I will habe the contacts of the two company or that of the first company in the list?

@laabidi21
Copy link

@captivea-ylb @escopecz @npracht Can you help on this one ?

@escopecz
Copy link
Member

I don't know these nuances from the top of my head. Please do some tests.

@laabidi21
Copy link

@escopecz How to get Custom Data Type (List of Country, List of region ...) of Fields WITH the API Library ?

@escopecz
Copy link
Member

I'm not aware of a API endpoint for those. But you can access them on GitHub directly. They are in JSON format. For example countries are here:

https://raw.githubusercontent.com/mautic/mautic/c9a0e09e62c03c91000e0b79578b744c11347f8f/app/bundles/CoreBundle/Assets/json/countries.json

@laabidi21
Copy link

@escopecz I used your proposal to find the contacts of a Company with: company: "Company name"
is it possible to find contacts who have no company in relation? (Without company in relationships)

@laabidi21
Copy link

@escopecz Please I used your proposal to find the contacts of a Company with: company: "Company name"
is it possible to find contacts who have no company in relation? (Without company in relationships)

@RCheesley RCheesley transferred this issue from mautic/mautic Jul 7, 2020
@laabidi21
Copy link

@escopecz it is possible to change the Label of the standard Field in Mautic from API ?
I have Version 3.0.1
// Get contact field context:
$fieldApi = $api->newApi("contactFields", $auth, $apiUrl);
$id = 1;
$data = array(
'label' => 'API test field',
'type' => 'text',
);

// Create new a field of ID 1 is not found?
$createIfNotFound = true;

$result = $fieldApi->edit($id, $data, $createIfNotFound);

I have a 500 type error. "message":"Looks like I encountered an error (error #500)

@escopecz
Copy link
Member

escopecz commented Oct 6, 2020

Should be possible. Check the logs what the error is.

@laabidi21
Copy link

@escopecz I didn't write the sql request. but I wrote the PHP code for API access. but it translates with the request:
An exception occurred while executing 'UPDATE lead_fields SET is_published = ?, date_modified = ?, modified_by = ?, modified_by_user = ?, label = ?, is_required = ?, is_visible = ?, is_short_visible = ?, is_listable = ?, is_unique_identifer = ?, field_order = ? WHERE id = ?'
with params [0, "2020-10-07 05:06:16", 3, "UserName", "Hauptadresse Stadt", null, null, null, null, null, 0, 13]: SQLSTATE[23000]: Integrity constraint violation: 1048 Column 'is_required' cannot be null" at PDOStatement.php:121

@escopecz
Copy link
Member

escopecz commented Oct 7, 2020

Alright. It's a bug then. The is_required property should be set to false if not provided. However there is a way around it if you provide the value in your API request. Try this:

$fieldApi = $api->newApi("contactFields", $auth, $apiUrl);
$id = 1;
$data = [
    'label' => 'API test field',
    'type' => 'text',
    'isRequired' => false,
];

// Create new a field of ID 1 is not found?
$createIfNotFound = true;

$result = $fieldApi->edit($id, $data, $createIfNotFound);

@laabidi21
Copy link

@escopecz when i set 'isRequired' false, it jumped to an error -> 'is_visible' cannot be null.
I will try to give value to all the attributes of the DB. can you be able to help me give me the right values (True or False)?
$data = array(
'label' => $vname,
'type' => $type,
'isRequired' => false,
'is_visible' => true,
'is_short_visible' => false,
'is_listable' => false,
'is_unique_identifer' => false,
);

@laabidi21
Copy link

laabidi21 commented Oct 7, 2020

@escopecz
With
$data = array(
'label' => $vname,
'type' => $type,
'isRequired' => false,
'is_visible' => false,
'is_short_visible' => false,
'is_listable' => false,
'is_unique_identifer' => false,
);
Error Log
'UPDATE lead_fields SET is_published = ?, date_modified = ?, label = ?, is_visible = ?, is_short_visible = ?, is_listable = ?, is_unique_identifer = ?, field_order = ? WHERE id = ?' with params [0, "2020-10-07 08:20:49", "Vorname", null, null, null, null, 0, 2]
-> SQLSTATE[23000]: Integrity constraint violation: 1048 Column 'is_visible' cannot be null -> despite 'is_visible' had the value FALSE in the array

@escopecz
Copy link
Member

escopecz commented Oct 7, 2020

Change the underscores with camel case as I did with the isRequired. E.g. is_visible => isVisible.

@laabidi21
Copy link

@escopecz
I have upgrade to version 3.0.1.
php var/www/html/mautic/bin/console mautic:segments:update
earlier, worked fine. but now after the upgrade I got an error.
PHP Warning: PHP Startup: Unable to load dynamic library 'mysqli' (tried: /usr/lib/php/20170718/mysqli (/usr/lib/php/20170718/mysqli: cannot open shared object file: No such file or directory), /usr/lib/php/20170718/mysqli.so (/usr/lib/php/20170718/mysqli.so: undefined symbol: mysqlnd_global_stats)) in Unknown on line 0
PHP Warning: PHP Startup: Unable to load dynamic library 'pdo_mysql' (tried: /usr/lib/php/20170718/pdo_mysql (/usr/lib/php/20170718/pdo_mysql: cannot open shared object file: No such file or directory), /usr/lib/php/20170718/pdo_mysql.so (/usr/lib/php/20170718/pdo_mysql.so: undefined symbol: pdo_parse_params)) in Unknown on line 0
Could not open input file: var/www/html/mautic/bin/console

@escopecz
Copy link
Member

@Ziedpad let's not mix completely different problem into this. Please create 1 GitHub issue for each problem you face. But in your case it's easier to find the answer when you google the error message. This is the first result: https://stackoverflow.com/questions/39204990/php-startup-unable-to-load-dynamic-library-usr-lib-php-20151012-php-mysqli-dll

@pintobikez
Copy link

Same problem here. It is very annoying to search companies. There are no filters available, and if the company name has accents, the search doesn't work at all.

Example, if I have a company named: John Farmacêutica, and I try to search for it, mautic will never return a value. I've tried to parse it to utf8 and encode the uri component and nothing....

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants