phpattaskworkfront-api

Adding Project Tasks using AtTask API


I am attempting to add a new task to a project in WorkFront (formerly known as AtTask). I have successfully been able to create a CURL connection to post the request, but the API only takes the task name and durations values. Any dateTime fields are ignored. Any suggestions on what I can do to set the task due date or the required completion dates? It must be really simple, but I am some how missing the it.

    $taskName = urlencode($_GET['newtask']);
    $attask_newtask_url = 'https://[my server name]/attask/api/v4.0/task';
    $now = time()+2880;

    $ch = curl_init();
    curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
    curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
    curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 30);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
    curl_setopt($ch, CURLOPT_URL, $attask_newtask_url);
    curl_setopt($ch, CURLOPT_POST, 1);
    curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query(array(
        'name'=>$taskName,
        'projectID'=>[my project id],
        'sessionID'=>$sessionID,
        'duration'=> (720/1440),
        'projectedStartDate'=>"07/27/2011"
    )));

Any help would be appreciated.

Thanks


Solution

  • Projected duration is a system calculated field that is not editable. To alter your start dates you would need to edit the plannedStartDate.

    for example your code should be.

     $taskName = urlencode($_GET['newtask']);
        $attask_newtask_url = 'https://[my server name]/attask/api/v4.0/task';
        $now = time()+2880;
    
        $ch = curl_init();
        curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
        curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
        curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 30);
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
        curl_setopt($ch, CURLOPT_URL, $attask_newtask_url);
        curl_setopt($ch, CURLOPT_POST, 1);
        curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query(array(
            'name'=>$taskName,
            'projectID'=>[my project id],
            'sessionID'=>$sessionID,
            'duration'=> (720/1440),
            'plannedStartDate'=>"07/27/2011"
        )));