I'm trying to query EspoCRM for any leads that might have a particular phone number. I am pretty sure my code is written correctly when I compare it to the PHP API example as a template (https://github.com/espocrm/documenta...arch-params.md)
No matter what values I pass or format I try for the params or where clause, they do not seem to be recognized. When I run this, I just get a list of all Leads in my CRM. I expect that my where and select clauses should be honored.
At the end of the day, when I'm done with this function, it will return the id of the lead that contains the phone number. I'd like to do as much of that processing inside the EspoCRM server by passing it the correct search parameters. I hope I don't have to resort to parsing the whole lead list in my code every time I run this function.
Is there something wrong with what I am doing?
My code:
No matter what values I pass or format I try for the params or where clause, they do not seem to be recognized. When I run this, I just get a list of all Leads in my CRM. I expect that my where and select clauses should be honored.
At the end of the day, when I'm done with this function, it will return the id of the lead that contains the phone number. I'd like to do as much of that processing inside the EspoCRM server by passing it the correct search parameters. I hope I don't have to resort to parsing the whole lead list in my code every time I run this function.
Is there something wrong with what I am doing?
My code:
Code:
#!/usr/bin/python3 import espoapi as crm endpoint = "https://myendpoint" client = crm.EspoAPI(endpoint, "my-api-key") def check_if_lead_exists_by_number_in_crm(phone: str):[INDENT]where = { 'value': {[/INDENT][INDENT=3]'type': 'contains', 'attribute': 'phoneNumber', 'value': phone[/INDENT][INDENT=2]}[/INDENT][INDENT] } params = {[/INDENT][INDENT=2]'select': 'id', 'where': where,[/INDENT][INDENT]} a = "Lead" r = client.request('GET', a, params ) total = r.get("total") list = r.get("list") print("Total: %s" % total) for record in list:[/INDENT][INDENT=2]print("Record: %s" % record)[/INDENT]
Comment