ssossossosso

Forums

Covering OroCRM topics, including community updates and company announcements.  Subscribe

This topic contains 10 replies, has 8 voices, and was last updated by Mike Kudelya Mike Kudelya 5 months, 2 weeks ago.

  • Creator
    Topic
  • #3732

    diglin
    Participant

    Hi,

    I try to use the REST API to create new contacts. I manage to create new contacts if there are only basics content like FirstName, LastName, jobTitle, etc however I have an issue when I try to add an email:
    – The field ’email’ seems to be not allowed, I get error saying This form should not contain extra fields: \"email\"
    – Using the field ’emails’ has no effect. No email is created if I send the following json string {"contact":{"firstName":"Sylvain","lastName":"Ray\u00e9","source":"vcard","emails":{"email":"slyatremoveddiglin.com","primary":true}}}

    Well after some research, I see that the entity Contact is associated to ContactEmail for the property “emails”. In the API Controller, there is no call to the Contact entity method “addEmail” as it is done to appendAccount.

    Do you plan something about that or if I provide a fix, do you think I’m in the good direction by adding to the API Rest controller ContactController and in the ContactHandler a logic to add Emails?

    Thank you for your feedback.

Viewing 10 replies - 1 through 10 (of 10 total)
  • Author
    Replies
  • #3749
    Dima Soroka
    Dima Soroka
    Oro Core

    We are going to add support of “email” field which will be saved as as primary email for a contact as well as support of /contacts/{id}/emails resource. Please fill free to contribute this improvements.

    #3758
    ignat
    ignat
    Oro Core

    Try to pass data in this format into your POST request:

    You should pass array of emails in contact.emails path. Try this:

    #3815

    diglin
    Participant

    Thank you to all for your feedbacks. I give a try and will notify you of the results 🙂

    #3876

    diglin
    Participant

    Thanks @ignat your tip worked. I used json_encode in PHP and how I did, was not sufficient.
    I had to better prepare the data by doing such a thing:

    “`
    $data = array(
    ‘firstName’ => ‘Sylvain’,
    ‘lastName’ => ‘Rayé’,
    ‘source’ => ‘vcard’,
    ’emails’ => array(array(’email’ => ‘sylvainremovedatdiglin.com’, ‘primary’ => true)));
    “`

    It could help other people.

    #4107

    raul782
    Participant

    Hi guys,

    Is there something I’m missing when creating new contacts
    I’m testing with curl and proper wsse header, but the payload is not being bound with the contact entity

    The error I get when debugging is

    Pretty much tells me that I’m sending the wrong format.

    I’m using the version 1.1

    #4108

    raul782
    Participant

    Hi guys,

    Ignore my post, It works alright now, the debugging part was my mistake.
    Curl command could be useful for anybody testing their Api.

    Thanks

    #6927

    lassers
    Participant

    Hi guys

    Thanks for the information to create a contact via REST API.
    After that, is there anybody tried to create an account as well? How can we set the defaultContact or contacts when we POST to /api/rest/latest/account?
    The code below did not work:

    Is there any suggestion?

    Thanks

    #16161

    miken
    Participant

    In case someone else runs into this question and needs an answer. I found that the defaultContact needs to be an Id of an existing contact in the system and passed through as default_contact.

    #23069

    keberdle
    Participant

    Hi how to add email for contact by API
    WE try:

    With error:

    OroRestApi: curl return http 400 for url https://ORO.ltd/api/contacts – [{“title”:”extra fields constraint”,”detail”:”Tato skupina pol\\u00ed nesm\\u00ed obsahovat dal\\u0161\\u00ed pole.”,”source”:”emails.0″},{“title”:”extra fields constraint”,”detail”:”Tato skupina pol\\u00ed nesm\\u00ed obsahovat dal\\u0161\\u00ed pole.”,”source”:”phones.0″}]

    #24767
    Mike Kudelya
    Mike Kudelya
    Oro Core

    Hi

    Here i described how to work with new json api.

Viewing 10 replies - 1 through 10 (of 10 total)

You must be logged in to reply to this topic.