Mautic Community Forums

Not able to fetch contacts listing by API calling

Hello All,

I am using mautic API for email listing and email sending. I am trying to get all email list with mautic API auth2.0
I am getting access token properly but while i am calling email api like this

$apiUrl = “https://travialist-main.scapp.io”;
$api = new MauticApi();
$emailApi = $api->newApi(“emails”, $auth, $apiUrl);
$emails = $emailApi->getList();
print_r($emails);

its giving me error

Array ( [errors] => Array ( [0] => Array ( [message] => Looks like I encountered an error (error #404). If I do it again, please report me to the system administrator! [code] => 404 [type] => ) ) [error] => Array ( [message] => Looks like I encountered an error (error #404). If I do it again, please report me to the system administrator! (error is deprecated as of 2.6.0 and will be removed in 3.0. Use the errors array instead.) [code] => 404 ) )

Can anyone please help me why its happening?

Hello EveryOne,

I have the same problem on create contact here is my code:

        $initAuth   = new ApiAuth();
        $auth       = $initAuth->newAuth($settings);
        $apiUrl     = "XXXXX";//url to Mautic
        $api        = new MauticApi();
        $contactApi = $api->newApi("contacts", $auth, $apiUrl);
             
             //CREATE Contact :
             
			$data = array(
			'firstname' => 'Jim',
			'lastname'  => 'Contact',
			'email'     => 'jim@his-site.com',
			'ipAddress' => $_SERVER['REMOTE_ADDR']
			);
			
			$contact = $contactApi->create($data);

and i get this :

Array ( [errors] => Array ( [0] => Array ( [message] => Looks like I encountered an error (error #404). If I do it again, please report me to the system administrator! [code] => 404 [type] => ) ) [error] => Array ( [message] => Looks like I encountered an error (error #404). If I do it again, please report me to the system administrator! (error is deprecated as of 2.6.0 and will be removed in 3.0. Use the errors array instead.) [code] => 404 ) )