Mautic rest api not working

Hi,



I’m having my external site. I want to export the users of my site to mautic. So, I decided to do with mautic rest API calls. To create the contact I send the data like

Code:
$data = array ( 'firstname' => 'test', 'email' => 'test@test.com', 'lastActive' => 2017-03-22 09:40:25 );

I post this data to the url https://test.mautic.net/api/contacts/new

What the weird thing. The contact is created. But the lastActive fields seem to "null".

Then, what I thought is the lastActive field will not update on contact creation. Hence, I update the same contact using the URL
https://test.mautic.net/api/contacts/CONTACTID/edit using "PATCH" call. But again I seen the lastActive is null.

What is the problem? Where I'm going wrong? Is there any bug in mautic API?

Hi @Sivananda Perumal try changing the date to the following format:

$data = array (
  'firstname' => 'test',
  'email' => 'test@test.com',
  'lastActive' => '2017-03-22T09:40:25+00:00'
);

e.g. it needs to be a string and in the format shown. Personally, I always use UTC timezone dates (+00:00) but you can try using a timezone relevant to you needs.

Hi,

I’m having my external site. I want to export the users of my site to mautic. So, I decided to do with mautic rest API calls. To create the contact I send the data like

$data = array ( 'firstname' => 'test', 'email' => 'test@test.com', 'lastActive' => 2017-03-22 09:40:25 );

I post this data to the url https://test.mautic.net/api/contacts/new

What the weird thing. The contact is created. But the lastActive fields seem to “null”.

Then, what I thought is the lastActive field will not update on contact creation. Hence, I update the same contact using the URL
https://test.mautic.net/api/contacts/CONTACTID/edit using “PATCH” call. But again I seen the lastActive is null.

What is the problem? Where I’m going wrong? Is there any bug in mautic API?

Thanks for your reply @MarkLL . I just tried the way you are specified in your comment. But it is not working for me.

Hey @Sivananda Perumal what version of Mautic are you using? The reason I ask, is because I fixed that bug in January and it was included in release 2.6.

Hi @MarkLL . I’m using v2.5.1 mautic. So, my version of mautic will not work for your code.

Can you please give me the patch file to update in my mautic?

Thanks @MxyzptlkFishStix !

@Sivananda Perumal If you look at it it’s a really simple fix!

Thanks @MxyzptlkFishStix and @MarkLL