BOX View API : Why am i getting the uploaded documnet status is queued..
Hi,
Am new to integrate the box view api and am using the php with curl for uploading the document to box(using the following code):
$URL = 'https://view-api.box.com/1/documents';
$apiKey = '<- redacted ->';
$filePath ='http://localhost/abc/upload/filename.pdf';
$file = json_encode(array('url'=>$filePath,'name'=>'Pdf File name'));
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $URL);
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
'Authorization: Token ' . $apiKey,
'Content-Type: application/json',
));
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $file);
$response = curl_exec($ch);
curl_close($ch);
$decodedata = json_decode($response);
$documentid = $decodedata->id;
Output:
stdClass Object( [type] => document [id] => 0fc7975523b846b899efdb9383184e4f [status] => queued [name] => PDF File name [created_at] => 2015-10-15T06:10:17.486Z)
everytime am getting the queued status on uploading the documnet. and i used this document id to create session mean am getting error or empty responce.
//for session creation
$_sessionURL = 'https://view-api.box.com/1/sessions';
$apiKey = '<- redacted ->';
$documentid = json_encode(array('document_id'=>$documentid,'duration'=>60));
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $_sessionURL);
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
'Authorization: Token ' . $apiKey,
'Content-type: application/json',
));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $documentid);
$response = curl_exec($ch);
curl_close($ch);
output :
empty responce...
So please guide me to solve this problem.
-
Hi,
Currently, when a document is uploaded to Box View, it goes through a few different stages which are reflected in the "status" parameter in the response.
The first stage is the document is "queued" as you are seeing in the response. If you check the status of the document by making this call:
https://box-view.readme.io/reference#get-documentsid
The status will change to "processing" when the document is being converted, and then to "done" when the document is finished, and is ready to create a session. If you attempt to create a session before the document status is "done" you will get a 202 response which includes a "Retry-After" header, but it has no body in the response, which is why it's currently empty.
You should wait until the document is done before attempting to create a session.
Also, as a side note, I removed the API keys from your request. Those should not be posted publicly, as they are the authentication step into your Box View instance.
Thanks,
Paul
-
Hi Paul or Box Team,
What is the equivalent of this in the new v2 Box API? How can I get the document status after I upload a file to know that the document is finished converting and ready to create a session? Or is this no longer needed when a document is uploaded using the new uploadFile API: https://upload.box.com/api/2.0/files/content
Thank you,
Ingrid
サインインしてコメントを残してください。
コメント
2件のコメント