0
Call API using PHP cURL. What's wrong with my code?
Explorer
,
/t5/acrobat-services-api-discussions/call-api-using-php-curl-what-s-wrong-with-my-code/td-p/13070770
Jul 14, 2022
Jul 14, 2022
Copy link to clipboard
Copied
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!
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting.
Learn more
Adobe Employee
,
/t5/acrobat-services-api-discussions/call-api-using-php-curl-what-s-wrong-with-my-code/m-p/13076527#M4427
Jul 18, 2022
Jul 18, 2022
Copy link to clipboard
Copied
The error code seems to suggest you are failing to create a multi-part request. I would recommed not re-inventing the wheel and simply using one of our SDKs -- we support multiple languages (not PHP, however). Some of the endpoints are a little involved, and in general we've created the SDKs to make your life easier.
https://developer.adobe.com/document-services/docs/overview/pdf-services-api/#sdk
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting.
Learn more
ilsh
AUTHOR
Explorer
,
LATEST
/t5/acrobat-services-api-discussions/call-api-using-php-curl-what-s-wrong-with-my-code/m-p/13086929#M4491
Jul 22, 2022
Jul 22, 2022
Copy link to clipboard
Copied
Thank you! Do you have any plans to make an SDK in PHP?
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting.
Learn more

