LiquidPlanner Classic Forum

Ask a Question
Back to All

Upload Documents via API


I'm having issues uploading files up to Liquid Planner through the use of the API.

In an effort to solve this, I even created a simple form that uploads a data file to a temporary file then attempts the upload by calling the API.

So far I found a complete example that should work provided in this form but still seem to not be having any luck.

Code Snip it:
$url = "" . $workspaceID . "/tasks/" . $taskId . "/documents";

$file = realpath($fileLocation);

$data = array(
"document[file_name]" => $fileName,
"document[description]" => $fileDesc,
"document[attached_file]" => "@".$fileLocation,


$conn = curl_init();
curl_setopt($conn, CURLOPT_HEADER, 0);
curl_setopt($conn, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($conn, CURLOPT_ENCODING, "");
curl_setopt($conn, CURLOPT_USERPWD, $email . ":" . $password );
curl_setopt($conn, CURLOPT_SSL_VERIFYPEER, 0);

curl_setopt($conn, CURLOPT_POST, true);
curl_setopt($conn, CURLOPT_URL, $url);
curl_setopt($conn, CURLOPT_POSTFIELDS, $data);

$response = curl_exec($conn);

print_r( $response."\n" );


This is what var_dump is reporting:

array (size=3)
'document[file_name]' => string 'ckt2.pdf' (length=8)
'document[description]' => string 'application/pdf' (length=15)
'document[attached_file]' => string '@C:\wamp64\www\EIS\uploads\ckt2.pdf' (length=35)
{"type":"Error","error":"BadArgument","message":"You must POST a document[attached_file] part when creating a document."}

I even went as far as to create a submit form coupled with a process file form to try to get this to work outside of my PHP App. If you would like me to send you the full source which is 2 files I'll be happy to do so.

Miguel Grajeda