# Mautic rest api not working

**URL:** <https://forum.mautic.org/t/mautic-rest-api-not-working/7986>\
**Category:** Product Support\
**Created:** [March 22, 2017, 4:53am UTC](https://forum.mautic.org/t/mautic-rest-api-not-working/7986 "2017-03-22T04:53:51Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![Sivananda\_Perumal](https://avatars.discourse-cdn.com/v4/letter/s/49beb7/32.png) [@Sivananda\_Perumal](https://forum.mautic.org/u/Sivananda_Perumal)\
**Post date:** [March 22, 2017, 4:53am UTC](https://forum.mautic.org/t/mautic-rest-api-not-working/7986/1 "2017-03-22T04:53:51Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![MarkLL](https://avatars.discourse-cdn.com/v4/letter/m/d9b06d/32.png) [@MarkLL](https://forum.mautic.org/u/MarkLL)\
**Post date:** [March 22, 2017, 10:33am UTC](https://forum.mautic.org/t/mautic-rest-api-not-working/7986/2 "2017-03-22T10:33:23Z")

</div>

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

```auto
$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.

---

<div class="post-metadata">

**Author:** ![Sivananda\_Perumal](https://avatars.discourse-cdn.com/v4/letter/s/49beb7/32.png) [@Sivananda\_Perumal](https://forum.mautic.org/u/Sivananda_Perumal)\
**Post date:** [March 22, 2017, 4:53am UTC](https://forum.mautic.org/t/mautic-rest-api-not-working/7986/3 "2017-03-22T04:53:51Z")

</div>

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](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](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?

---

<div class="post-metadata">

**Author:** ![Sivananda\_Perumal](https://avatars.discourse-cdn.com/v4/letter/s/49beb7/32.png) [@Sivananda\_Perumal](https://forum.mautic.org/u/Sivananda_Perumal)\
**Post date:** [March 23, 2017, 7:00am UTC](https://forum.mautic.org/t/mautic-rest-api-not-working/7986/4 "2017-03-23T07:00:50Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![MarkLL](https://avatars.discourse-cdn.com/v4/letter/m/d9b06d/32.png) [@MarkLL](https://forum.mautic.org/u/MarkLL)\
**Post date:** [March 23, 2017, 11:49am UTC](https://forum.mautic.org/t/mautic-rest-api-not-working/7986/5 "2017-03-23T11:49:49Z")

</div>

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](https://github.com/mautic/mautic/releases/tag/2.6.0).

---

<div class="post-metadata">

**Author:** ![Sivananda\_Perumal](https://avatars.discourse-cdn.com/v4/letter/s/49beb7/32.png) [@Sivananda\_Perumal](https://forum.mautic.org/u/Sivananda_Perumal)\
**Post date:** [April 27, 2017, 8:06am UTC](https://forum.mautic.org/t/mautic-rest-api-not-working/7986/6 "2017-04-27T08:06:29Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![MarkLL](https://avatars.discourse-cdn.com/v4/letter/m/d9b06d/32.png) [@MarkLL](https://forum.mautic.org/u/MarkLL)\
**Post date:** [April 28, 2017, 12:25am UTC](https://forum.mautic.org/t/mautic-rest-api-not-working/7986/7 "2017-04-28T00:25:36Z")

</div>

Thanks @MxyzptlkFishStix !

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

---

<div class="post-metadata">

**Author:** ![Sivananda\_Perumal](https://avatars.discourse-cdn.com/v4/letter/s/49beb7/32.png) [@Sivananda\_Perumal](https://forum.mautic.org/u/Sivananda_Perumal)\
**Post date:** [May 5, 2017, 8:35am UTC](https://forum.mautic.org/t/mautic-rest-api-not-working/7986/8 "2017-05-05T08:35:45Z")

</div>

Thanks @MxyzptlkFishStix and @MarkLL
