I have been trying to create a php function to call PDF extract API. I always got the following error:
{"requestId":"IEt94LRYdvDw4Xd9rzzcTqYt4dwWa1Sc","type":"Bad Request","title":"Not a multipart request. Aborting.","status":400,"report":"{\"error_code\":\"INVALID_MULTIPART_REQUEST\"}"}
My code is below:
$cfile = curl_file_create($pdf_file);
$ch = curl_init();
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, array("fileInput1"=>$cfile,"contentAnalyzerRequests"=>"{ \"cpf:engine\": { \"repo:assetId\": \"urn:aaid:cpf:58af6e2c-1f0c-400d-9188-078000185695\" }, \"cpf:inputs\": { \"documentIn\": { \"cpf:location\": \"fileInput1\", \"dc:format\": \"application/pdf\" }, \"params\": { \"cpf:inline\": { \"elementsToExtract\": [ \"text\", \"tables\" ], \"renditionsToExtract\": [ \"tables\", \"figures\"] } } }, \"cpf:outputs\": { \"elementsInfo\": { \"cpf:location\": \"jsonoutput\", \"dc:format\": \"application/json\" }, \"elementsRenditions\": { \"cpf:location\": \"fileoutpart\", \"dc:format\": \"text/directory\" } } }"));
curl_setopt($ch, CURLOPT_POST, 1);
$headers = array();
$headers[] = "Accept: application/json, text/plain";
$headers[] = "Authorization: Bearer $token";
$headers[] = "x-api-key: $client_id";
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
$result = curl_exec($ch);
Can anybody help me? Thanks!