2

I am creating API for creates task in Active Collab and I have been successful for get and set name of new task, message and due date.

However, when I insert image or file it's not creating task.

Below is my code so please help me to solve it.

try {
    API::call('projects/60/tasks/add', null, array(
        'task[name]' => $_POST['name'],
        'task[body]' => $_POST['message'],
        'task[priority]' => $priority,  
        'task[due_on]' => $date,
        'task[assignee_id]' => 21,
    ), array(
       'a.png' /* This array is for attach image to this task but not working in my case and I found this from https://help-classic.activecollab.com/books/api/sdk.html */
    ));
    echo 'Ticket Created Successfully.';

} catch(AppException $e) {
    print $e->getMessage() . '<br><br>';
    var_dump($e->getServerResponse());
}
Ryan Vincent
  • 4,483
  • 7
  • 22
  • 31
Dhaval
  • 1,393
  • 5
  • 29
  • 55

1 Answers1

0

Please replace a.png with an absolute path to an existing file on file system, for example /path/to/my/image.png.

Ilija
  • 4,105
  • 4
  • 32
  • 46
  • @llija I have applied full path before asking question here however it didn't work. so please if you have any other solution then you can help me. – Dhaval Apr 25 '16 at 06:35
  • That's how request with files is prepared. I'm unsure why it does not work in your env. – Ilija Apr 25 '16 at 16:33
  • @llija can you help me to attach image using Active collab API.I tried below code but it's not working. try{ API::call('projects/60/tasks/add', null, array( 'task[name]' => $_POST['name'], 'task[body]' => $_POST['message'], ), array( 'http://test.bathcomms.com/skin/frontend/bathcomms/default/images/logo.png )); } – Dhaval May 03 '16 at 05:59
  • Try with absolute file path, not relative one. – Ilija May 03 '16 at 07:48
  • @llija ok I will try that way too but can you check this question http://stackoverflow.com/questions/36997075/active-collab-notify-user-when-create-close-or-reopen-task-using-api – Dhaval May 03 '16 at 07:51
  • I provided the correct answer 10 days ago. That IS THE ANSWER ;-) – Ilija May 03 '16 at 07:52
  • @llija I have asked new question please check below link http://stackoverflow.com/questions/36997075/active-collab-notify-user-when-create-close-or-reopen-task-using-api – Dhaval May 03 '16 at 07:57
  • I hope you will have definitely solution for this new question. – Dhaval May 03 '16 at 07:59