API Create for Tasks/Calls etc where there are linked records

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • mkas
    Junior Member
    • Feb 2021
    • 26

    API Create for Tasks/Calls etc where there are linked records

    Hi there,
    I am trying to make an API call to create tasks or calls that are linked to the assigned user.

    This is the code that I am using for the actual call, but I am getting an ERROR (403) message.
    I have checked the API user and they have full access.

    Am I missing something - I am using PHP.

    The path that is being called in the $client->request is POST /User/1/Task (the user-id I am trying to use is 1)

    Code:
    $emailAddress = $response['list'][0]['emailAddress'];
    $parent = $response['list'][0]['id'];
    $user = $response['list'][0]['assignedUserId'];
    
    
    if($formEmailAddress !== $emailAddress) {
    $formerror = 'Sorry, your email address does not match the one of file. Please try again.';
    } else {
    $params = [
    'name' => 'Call Back Requested',
    'priority' => 'High',
    'parent' => $parent,
    'description' => $desc,
    'dateStartDate' => $dueDate,
    ];
    
    }
    
    try {
    
    $response = $client->request('POST', 'User/' . $user . '/Task', $params);
    
    } catch (\Exception $e) {
    $errorCode = $e->getCode();
    $formerror = 'We had an issue processing your request. Please try again later.<br>
    Error code: ' . $errorCode;
    }

  • emillod
    Active Community Member
    • Apr 2017
    • 1405

    #2
    You should send whole payload to /api/v1/Task
    Type of request should be POST. If you have any issues you should open console in your browser, open network tab, create new task and check requests.

    Comment

    • mkas
      Junior Member
      • Feb 2021
      • 26

      #3
      Hi emillod ,

      Thank you so much!
      I had tried that before I tried the other way - but I just realised I made a mistake.
      I had used the variable assignedUser in the payload, when it should have been assignedUserId.

      Thanks heaps!

      Comment

      Working...