Announcement

Collapse
No announcement yet.

REST API - Set Multiple phone numbers / email adresses via POST / PUT

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • REST API - Set Multiple phone numbers / email adresses via POST / PUT

    First of all hello - my first post
    Espo is really a great software!
    So I think I might be missing something.

    I want to add multiple phone numbers and email addresses to a contact via REST API.

    We connect external systems with our turm.ai to Espo. Thereby the addresses are didirectionally synced. However, the addresses often have multiple email addresses and phone numbers.
    The sync also works well, except for the missing multiple phone numbers / email addresses.

    So I am missing the starting point how to change the phone numbers purely via REST API.


    Exemplary with the phone numbers by exserted:

    what I can do:
    - set a phone number via POST with phoneNumber.
    - Update phone number via PUT
    - see all phone numbers in the phoneNumberData

    what I cannot do:
    - add another phone number
    - change the type of the phone number (always the default type)


    what I tested:
    - change phoneNumberData via POST or PUT
    - use phoneNumberMobile or similar
    - update several times with different phone numbers.



    Posts aiming in the same direction:
    Hi, I'm working on a migration project, and I have 2 questions: a) How do I import multiple contact phones? /api/v1/Contact/{id}/PhoneNumber is not available... If I send a GET to /api/v1/Contact/{id}, I get only one phone number. Who can I get all of them? b) Customer would like to import history contacts from the old




    EspoCRM – Open Source CRM Application. Contribute to espocrm/espocrm development by creating an account on GitHub.



    Thanks a lot
    Max​​

  • #2
    Hi Max,

    The attribute phoneNumberData should work. If you want to add to an existing list, first you need to fetch the record (e.g. a Contact). Add the new number to phoneNumberData and then send PUT request with the payload: {"phoneNumberData": [...]}.

    If you open the browser console (F12) > Network tab, you can see what API requests the front-end is sending when your are editing email/phone fields.

    Comment


    • #3
      Hi yuri,
      thanks for the quick support!

      As suspected, I really made a mistake:

      I had all records on primary false.

      This leads to the fact that no record is displayed in the list, but in the record itself. If there is a phone number in the list, it can't be set to primary, only if another one is added.

      Since no prioritization comes from the external system, I set all phone numbers to primary true, espo then sets the last record of the list to true, so it is ensured that there is always a phone number on primary.

      Here are my lessons leand for you guys:

      - The assignment of the types follows the original values in the configuration, not the translation (like everywhere in the API). But some customers create their own terms and don't pay attention to the english spelling.
      - better set too much primary than too little (if no decision can be made just set all to true)
      - empty phone numbers ("") are not valid, in this case the whole object must be left out of the list
      - Empty lists are ok

      Best regards
      Max​

      Comment

      Working...
      X