Announcement

Collapse
No announcement yet.

API - Related records

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

  • API - Related records

    Hi!

    I tried to link an n:1 resp. 1:n relationship vie API as described in the docs https://docs.espocrm.com/development...ionships/#link

    But this doesn't work:
    Code:
    WARNING: (403) Only manyMany, hasMany & hasChildren relations are allowed.
    Is there another way to link them or am I doing something wrong?

    I would appreciate any help!

  • #2
    Hi,

    It's in the release notes https://github.com/espocrm/espocrm/releases/tag/8.1.0, https://github.com/espocrm/espocrm/issues/2882. There were reasons to do it, it was not supposed to have this ability from the beginning, but we had it that was a mistake that led us to problems.

    As it's stated in the issue, you have to use a regular PUT request. Updating a record by setting an ID of the foreign record. It's literally the same what the method did internally before.

    Code:
    PUT https://your_url/api/v1/EntityType/recordId
    
    {
        "linkId": "foreignRecordId"
    }
    Where 'link', is the link name.

    As an alternative, you can create a custom API endpoint.

    The documentation does not stipulate n:1 support. It states that it's possible to pass a single ID instead of array of IDs.
    Last edited by yuri; 01-30-2024, 10:03 AM.

    Comment


    • #3
      Thanks yuri. Didn't know I can just use a PUT request. That helped me a lot!

      Comment

      Working...
      X