LiquidPlanner Classic Forum

Ask a Question
Back to All

Update Task Description - task_update

(edited)

Posted on behalf of a customer. Original posting date 2017-01-12.

What is the correct URL and JSON format?

Here is my code, and don't worry about the $super_user_lp, it is working. Only the task_update is not working, and has no response by thisAPI call.

$response_update_task_prefix = $super_user_lp->task_update($task_id, $update_data);

/*
$update_data['name'] = "Prefix"."Original Task Name";
$update_data['description'] = "Prefix"."Original Description";
//By the way, may I update the Note like this:?
$update_data['note'] = "New Note"."Original Note";
*/
function task_update($taskid, $data){
$encodedTask = json_encode(array('task' => $data));
$url = 'https://app.liquidplanner.com/api/workspaces/{space ID}/tasks/'.$taskid;
$response = $this->lp_put($url, $encodedTask);
return($response);
}
function lp_put($endpoint_url, $encodedTask){

$curl = curl_init($endpoint_url);
curl_setopt($curl, CURLOPT_HEADER, false); //$conn
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_USERPWD, trim($this->email).":".trim($this->password));
curl_setopt($curl, CURLOPT_HTTPHEADER, array("Content-Type: application/json"));
curl_setopt($curl, CURLOPT_ENCODING, "gzip");
// curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
// curl_setopt($curl, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "PUT");
curl_setopt($curl, CURLOPT_URL, $endpoint_url);
// curl_setopt($curl, CURLOPT_POSTFIELDS, $encodedTask);
curl_setopt($ch, CURLOPT_POSTFIELDS,http_build_query($encodedTask));
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
$response = curl_exec( $curl );
$error = curl_error($curl);
// curl_close($curl);
$results = json_decode($response, true);
return $results;
}