Mautic Community Forums

add contact data to mautic Oauth 2 rest api

Code:
Hi,

I have used Oauth 2 rest api on my site.
I am trying to add the contacts on mautic but getting follwing error :-

{“errors”:[{“message”:“Looks like I encountered an error (error #404). If I do it again, please report me to the system administrator!”,“code”:404,“type”:null}],“error”:{“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}}

here is my code :-
$contact_data = array(
‘firstname’ => $first_name,
‘lastname’ => $last_name,
‘email’ => $email
);
$data_json = json_encode($contact_data);

	echo $data_json;
	//echo $url_con="https://ecomhorizons.taurosmail.com/api/contacts/new?firstname=John&lastname=Smith&access_token=".$access_token;
	
   $url_con	=	"https://ecomhorizons.taurosmail.com/api/contacts/new/?access_token=".$access_token;
	$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url_con);
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/json'));
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS,$data_json);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$response  = curl_exec($ch);
curl_close($ch);
	 print_r($response); 

please help me .

Thanks

[code]Hi,

I have used Oauth 2 rest api on my site.
I am trying to add the contacts on mautic but getting follwing error :-

{“errors”:[{“message”:“Looks like I encountered an error (error #404). If I do it again, please report me to the system administrator!”,“code”:404,“type”:null}],“error”:{“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}}

here is my code :-
$contact_data = array(
‘firstname’ => $first_name,
‘lastname’ => $last_name,
‘email’ => $email
);
$data_json = json_encode($contact_data);

	echo $data_json;
	//echo $url_con="https://ecomhorizons.taurosmail.com/api/contacts/new?firstname=John&lastname=Smith&access_token=".$access_token;
	
   $url_con	=	"https://ecomhorizons.taurosmail.com/api/contacts/new/?access_token=".$access_token;
	$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url_con);
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/json'));
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS,$data_json);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$response  = curl_exec($ch);
curl_close($ch);
	 print_r($response); 

please help me .

Thanks[/code]