I cant create a lead with the HTTP REST API

Hello would someone be able to help out?



I CANNOT CREATE a contact



Header

Authorization: Bearer {token}



POST http://dev.mautic.mydomain.com/api/contacts/new



The response is:



{

“error”: {

“message”: “Requested URL not found: /index.php/api/contacts/new”,

“code”: 404

}

}



But I have managed to do all the following calls with the REST API, testing through POSTMAN



Header

Authorization: Bearer {token}



Get contact

GET http://dev.mautic.mydomain.com/api/contacts/1



Search contact

GET http://dev.mautic.mydomain.com/api/contacts?search=david



Edit contact

PUT http://dev.mautic.mydomain.com/api/contacts/1/edit

Hello would someone be able to help out?

I CANNOT CREATE a contact

Header
Authorization: Bearer {token}

POST http://dev.mautic.mydomain.com/api/contacts/new

The response is:

{
“error”: {
“message”: “Requested URL not found: /index.php/api/contacts/new”,
“code”: 404
}
}

But I have managed to do all the following calls with the REST API, testing through POSTMAN

Header
Authorization: Bearer {token}

Get contact
GET http://dev.mautic.mydomain.com/api/contacts/1

Search contact
GET http://dev.mautic.mydomain.com/api/contacts?search=david

Edit contact
PUT http://dev.mautic.mydomain.com/api/contacts/1/edit

Its really weird every other operation is alright except for the most important one which is create. May i know what im doing wrong?

Oh btw… im using the latest 2.01 Mautic

It might be related to https://github.com/mautic/mautic/pull/2142. Try to save only one contact field which you know has a valid value. For example firstname doesn’t have any validation on it. If it saves correctly, then you send some value which gets rejected by the form value validation. You should also find some error messages in the Mautic logs.

Actually i managed to create a contact by doing this trick

http://dev.mautic.rapidfy.com/api/contacts/0/edit

because i looked in your code and saw a create if not exist. Do you still think this error with …/new is related to the above git report?

Should i update my mautic with the bugfix?

If you’d be able to test that PR, that’d be great! It’ll speed up the 2.1.0 release and you can win prizes this month:

https://www.mautic.org/blog/community/mautic-summer-games/