Hey,
I've been trying to add contacts Using the API but I've been facing issues in it, if someone could guide me in what I am doing wrong it would be helpful.
Here is what I've written
But when I return $response->getData(), I always get this:
{"ErrorInfo":"","ErrorMessage":"Invalid json input: object \"\"->\"TContact\" has no property \"firstname\"","StatusCode":400}
The properties are already added, here is a screenshot showing it:
I've also tried creating contacts in lists directly (Replaced list ID with a dummy ID, before posting here)
But this gives me the Error, "Email is not valid" on the website..
I know I am probably doing something incorrectly but I am genuinely not sure what it is, any guidance on this is really appreciated. Thank you.
Edit: Would just like to mention if it is useful, I have tried creating a contact directly from the website without API and that works fine.
Hey, I've been trying to add contacts Using the API but I've been facing issues in it, if someone could guide me in what I am doing wrong it would be helpful. Here is what I've written
$mj = new \Mailjet\Client($apikey, $apisecret, true, ["version" => "v3"]); $body = [ "IsExcludedFromCampaigns" => "true", "email" => "ashmit@xyz.com", "firstname" => "Ashmit", "lastname" => "Shetty", "phone" => "123456", "gender" => "M", "birthday" => "22/09/1997", "dexcom" => "Dummy", "zugehoerigkeit" => "Dummy" ]; $response = $mj->post(Resources::$Contact, ["body" => $body]); $response->success() && var_dump($response->getData());
But when I return $response->getData(), I always get this: {"ErrorInfo":"","ErrorMessage":"Invalid json input: object \"\"->\"TContact\" has no property \"firstname\"","StatusCode":400}
The properties are already added, here is a screenshot showing it:
I've also tried creating contacts in lists directly (Replaced list ID with a dummy ID, before posting here)
$mj = new \Mailjet\Client($apikey, $apisecret, true, ["version" => "v3"]); $listId = "123456"; $body = [ "Action" => "addforce", "Contacts" => [ [ "Email" => "ashmit@xyz.com", "IsExcludedFromCampaigns" => "false", "firstname" => "Ashmit", "lastname" => "Shetty", "phone" => "123456", "gender" => "M", "birthday" => "22/09/1997", "dexcom" => "Dummy", "zugehoerigkeit" => "Dummy" ] ] ]; $response = $mj->post(Resources::$ContactslistManagemanycontacts, ["id" => $listId, "body" => $body]); $response->success() && var_dump($response->getData());
But this gives me the Error, "Email is not valid" on the website.. I know I am probably doing something incorrectly but I am genuinely not sure what it is, any guidance on this is really appreciated. Thank you.
Edit: Would just like to mention if it is useful, I have tried creating a contact directly from the website without API and that works fine.