Search code examples
phpmagentomagento-1.9activecollab

Complete Active Colab Task Using API


I am integrating Active Colab with my Magento site. I have successfully created a new task using API but I want to complete this task using API.

So what I want to do is if I complete the task in Active Collab that task automatically be completed on my website (all task list is shown on my site too.) And if I complete a task from my site it will be completed in Active Collab.

Above functionality, I want to implement using Active Collab API.

So if there is anyone who can help me to solve this problem thank you in advance.

if($status == 1){$complete = false;} /*open status*/
if($status == 3){$complete = true;}  /*closed status*/

try {
    $res = API::call('projects/60/tasks/176/put', null, array(
    'task[is_completed]' => $_POST['is_completed'], /*$complete used here*/         
    ));
    //$GLOBALS['$myValue'] = $res['permalink']; 
    //echo $GLOBALS['$myValue'];
    echo 'Ticket Updated Successfully.';  
    
    
} catch(AppException $e) {
  print $e->getMessage() . '<br><br>';
  // var_dump($e->getServerResponse()); (need more info?)
} // try 

I have changed some code for the update task as a complete that is below so please check and let me know if there is any wrong code.

try {
    $res = API::call('projects/60/tasks/176/put', null, array(
    'task[is_on]' => 1,     
    ));
    echo 'Ticket Updated Successfully.';        
} catch(AppException $e) {
  print $e->getMessage() . '<br><br>';
}

Solution

  • To complete a task in Active Collab 4 via API, you need to send POST request to /projects/:project_id/tasks/:task_id/complete route. Your example uses Active Collab PHP SDK, so here's an example:

    API::call('projects/60/tasks/176/complete', null, [
        'submitted' => 'submitted',
    ]);
    

    Documentation about complete command can be found here:

    https://help-classic.activecollab.com/books/api/complete.html

    More info about task routes and task context is available here:

    https://help-classic.activecollab.com/books/api/tasks.html