Announcement

Collapse
No announcement yet.

API :: Related records - Linking Account and Contact

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

  • API :: Related records - Linking Account and Contact

    I'm following https://docs.espocrm.com/development/api/relationships/ and try the example to link Account with Opportunity without problem. Including Opportunity with Contact and Lead.

    However I can't link Account with Contact (using python):

    payload1 = {"id": "65ead2d200305d970",}
    print(client.request('POST', 'Contact/65eae820758e89231/account', payload1))​

    Got:
    <Response [403]>
    Traceback (most recent call last):
    File "espotest.py", line 12, in <module>
    print(client.request('POST', 'Contact/65eae820758e89231/account', payload1))
    File "/home/hendro/Downloads/espo_api_client.py", line 73, in request
    raise EspoAPIError(f'Wrong request, status code is {response.status_code}, reason is {reason}')
    espo_api_client.EspoAPIError: Wrong request, status code is 403, reason is Only manyMany, hasMany & hasChildren relations are allowed.​

    payload1 = [{"id": "65ead2d200305d970",}]
    print(client.request('POST', 'Contact/65eae820758e89231/account', payload1))​

    ​Got:
    <Response [200]>
    False

    Appreciate for any hint..

  • #2
    You cannot use link/unlink API operations for hasOne, belongsTo links. Either link from the opposite side or update a record by setting a foreign ID attribute, e.g. accountId.

    Comment

    Working...
    X