Can not create link in rest api

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • dafnie
    Senior Member
    • Dec 2015
    • 140

    Can not create link in rest api

    What am i doing wrong. I can not create any links via Rest API.
    All other rest functions are working fine. GET and POST

    1. Created a API user "test", with api-key "0de7d71a2128c275ea742b3144f7a12f"

    2. GET "https://demo.espocrm.com/api/v1/Contact", header "Content-type: application/json", X-Api-key: 0de7d71a2128c275ea742b3144f7a12f" - RESPONSE: 200

    3. POST "https://demo.espocrm.com/api/v1/Contact" header "Content-type: application/json", X-Api-key: 0de7d71a2128c275ea742b3144f7a12f" - RESPONSE: 200

    4. POST "https://demo.espocrm.com/api/v1/Task" header "Content-type: application/json", X-Api-key: 0de7d71a2128c275ea742b3144f7a12f" - RESPONSE: 200

    4. POST "https://demo.espocrm.com/api/v1/Contact/60c5af36bcc9a3528/Task"
    Body: { "id": "5a7d839facfcf" } - RESPONSE: 500


    Why am i getting 500 when trying to link a Task to Contact??
    I have tested other entetys but all response 500

    **EDIT**
    I think i had to use the parentId in the body when i create the Task.
    But anyway the response should not be 500.
    Last edited by dafnie; 06-13-2021, 11:16 PM.
  • Maximus
    Senior Member
    • Nov 2018
    • 2731

    #2
    Hi,
    What are you trying to do?
    If you want to get the Contact entry data, your URL should look like - GET: https://demo.espocrm.com/api/v1/Contact/53203b94287eb
    If you want to create a new Contact entry, your URL should look like - POST: https://demo.espocrm.com/api/v1/Contact

    53203b94287eb - it's the id of contact.
    Last edited by Maximus; 06-14-2021, 05:43 PM.

    Comment


    • dafnie
      dafnie commented
      Editing a comment
      Thanks for the reply.
      Yes I agree on the URL for Get and POST, but the problem is 4. when trying to create af link between to entities.
      I allways get a response 500.
  • Maximus
    Senior Member
    • Nov 2018
    • 2731

    #3
    What do you mean to create a link between entities? As far as I am aware of EspoCRM doesn't handle requests like: demo.espocrm.com/api/v1/first-entity/id/second-entity
    Are you trying to create a new relationship between entities, or just link one entity's entry with another entity's entry via an already existed relationship?

    Comment


    • dafnie
      dafnie commented
      Editing a comment
      I am trying to do what is explained here: https://docs.espocrm.com/development...ionships/#link
      Maybe the problem is that there is a different between parent/child relation and Related records.

    • esforim
      esforim commented
      Editing a comment
      I think dafnie want to do something like this;

      Contact: Mr Maximus
      Account: EspoCRM

      Post request: contact:120313(maximus) create link relationship to account:1230419(espocrm)

      But instead of account he want to link it to a task?
  • Maximus
    Senior Member
    • Nov 2018
    • 2731

    #4
    > I am trying to do what is explained here:

    I see. Try it this way: POST "https://demo.espocrm.com/api/v1/Contact/60c5af36bcc9a3528/tasks"
    Where:
    60c5af36bcc9a3528 - ID of the record to relate with
    tasks - the name of a default relationship between Contact-Tasks

    Comment

    Working...