LiquidPlanner Classic Forum

Ask a Question
ANSWERED
ANSWERED
ANSWERED
ANSWERED
ANSWERED
ANSWERED

Uploading a file to the task. [PHP] [cURL] [REST API]

*Posted on behalf of John Z. Original posting date 2012-11-26.* Hello, I am using the php client that you can get on [github](https://github.com/jonoxer/php-liquidplanner). I am having trouble uploading a file to a task. Well, this file is actually a string, and I want to upload that string as the file to the task. Below are two functions that I am using that I added to the client. ``` $data = the string that I want uploaded as a txt file. $taskid is the correct id for the task. public function attachDocument($data, $taskid) { $encodedData = array('attached_file' => $data, 'file_name'=>'testing.txt'); $url = $this->serviceurl . '/tasks/' . $taskid . '/documents'; $response = $this->lp_attach_file($url, $data); return($response); } private function lp_attach_file($url, $data) { /* Set up the CURL object and execute it */ $conn = curl_init(); curl_setopt($conn, CURLOPT_HEADER, false); // Suppress display of the response header curl_setopt($conn, CURLOPT_HTTPHEADER, array("Content-type: multipart/form-data")); curl_setopt($conn, CURLOPT_RETURNTRANSFER, true); // Return result as a string curl_setopt($conn, CURLOPT_POST, true); // Submit data as an HTTP POST curl_setopt($conn, CURLOPT_POSTFIELDS, $data); // Set the POST field values curl_setopt($conn, CURLOPT_ENCODING, ""); // Prevent GZIP compression of response from LP curl_setopt($conn, CURLOPT_USERPWD, $this->email . ":" . $this->password); // Authenticate curl_setopt($conn, CURLOPT_URL, $url); // Set the service URL curl_setopt($conn, CURLOPT_SSL_VERIFYPEER, false); // Accept any SSL certificate $response = curl_exec($conn); curl_close($conn); /* The response is JSON, so decode it and return the result as an array */ $results = json_decode($response, true); /* Check for Throttling from the API */ if ((isset($results['type']) && $results['type'] == "Error") && (isset($results['error']) && $results['error'] == "Throttled")) { //We're being throttled. Waith 15 seconds and call it again. $this->throttle_message(); sleep($this->throttlewait); return $this->lp_post($url, $data); } return $results; } ``` I get a response from curl_exec, which is: ``` "{"type":"Error","error":"BadArgument","message":"Expected a hash of attribute values for document parameter"}" ``` I have been messing with this a while now, if anyone could help me out or give me some examples I would really appreciate it! Let me know if I can provide you with any more info about the program. Thanks!!
ANSWERED

How to update ownership and estimates correctly ?

*Posted on behalf of Thibaud. Original posting date 2014-10-27.* Hi, We use LiquidPlanner (LP) to manage projects (mostly for planning) but JIRA for the time tracking. We developped an application that synchronises JIRA to LP (one-way). So we can create new tasks, update info (owner/assignee, low/high estimate, description, etc.). We don't mind much about work log (who does what) we just want to make sure the time left, assignee and done status of tasks in JIRA are properly updated in LP. With the new changes, the part that I don't quite get is the multiple assignments. As there is no way to test it before it's too late, this scares me a bit because having the synchronization work became critical in our organization. When all I want is to make sure the owner of the task reflects the assignee in JIRA and that the remaining estimates (low and high) are up to date (we use the track_time service to update the difference between JIRA and LP), what are the precautions I have to take ? Because I read that assigning the same person to a task will throw an error. Do I use the track_time service the same way I used it in the past (but adding the person_id) for time tracking ? Do I have to delete extra assignments ? If we want to have only one assignee, do we simply update an assignment based on its ID ? My plan is to do this: 1- update all task info except estimates and ownership 2- update the owner: 2.a. if the task.assignments[0].person_id == <owner id> => do nothing (is there a risk of having multiple assignements?) 2.b. otherwise, send a request to /update_assignment with {"assignment_id": task.assignments[0].id, "person_id": <owner id>} 3- update the estimates (I use the same request to /time_tracking with the difference in estimates in JIRA and LP and the person_id being the <owner id>) Is that OK ? I have a feeling that there's a risk of having assignments with person_id: 0 (Unassigned user) or worse, if people for a reason or another change ownership (and log work??) in LP, there will be multiple assignments. Sorry if my questions aren't clear enough, if you need any clarification, don't hesitate to ask. Thanks for the help. - Thibaud -
ANSWERED
ANSWERED
ANSWERED