In the API all of the methods require the leadId pretty much. But there is no way (that I have found) that I can get the leadId. Even upon createLead the return is a 201, but is there any data?
Is there a way to fetch the leadId based on an email? Or is there some other way? I would REALLY love to use this API now that I have gotten it to work and now have hit this stumbling block.
Thanks Guys!
John
In the API all of the methods require the leadId pretty much. But there is no way (that I have found) that I can get the leadId. Even upon createLead the return is a 201, but is there any data?
Is there a way to fetch the leadId based on an email? Or is there some other way? I would REALLY love to use this API now that I have gotten it to work and now have hit this stumbling block.
Thanks Guys!
John
I just made a test if the Mautic API returns the lead data back after creation. It does. No idea why you don’t see it. Here is the screenshot:
The “search lead by a field” API request would be helpful I guess. Could you create an issue on GitHub so developers could track it? https://github.com/mautic/mautic/issues
I did a search via email so I did a search via email in this way. Other way is not found.
[code]
private function getContactByEmail($email)
{
$email = mb_strtolower($email);
$auth = $this->Auth();
$leadApi = MauticApi::getContext("leads", $auth, $this->apiUrl);
$lead = $leadApi->getList();
foreach($lead['leads'] as $key => $value){
if($value['fields']['all']['email'] == $email){
return $lead['leads'][$key];
}
}
return false;
}[/code]
Yeah, this is the only possible way how to do it right now. It is not possible solution for bigger amount of leads. It will end up run time limit error, memory limit error or it will process leads for very long time.