Convert Microsoft PowerPoint Presentation to PDF in PHP using Aspose.Slides REST API throwing 400 Bad Request

The code I’m using hasn’t been touched in a long time and was previously working. Has there been any changes to the https://api.aspose.cloud/v3.0/slides/convert/Pdf api?

Here is a link to the file I’m trying to save as PDF

https://emiboston0-my.sharepoint.com/:p:/g/personal/klubar_emiboston_com/EeTyc3_R0i1OpMdJn7NAHQgBsaWEEiWF1Rqn0hnm4B1CGQ?e=uZfjKo

Here is the error message that is being thrown:

Fatal error* : Uncaught Aspose\Slides\Cloud\Sdk\Api\ApiException: [400] Client error: POST https://api.aspose.cloud/v3.0/slides/convert/Pdf resulted in a 400 Bad Request response: {“error”:{“code”:“error”,“message”:“Incorrect Content-Type: application/octet-stream,multipart/form-data”,“description”: (truncated…) in /var/www/emi/composer/vendor/aspose/slides-sdk-php/sdk/Api/ApiBase.php:84 Stack trace: #0 /var/www/emi/composer/vendor/aspose/slides-sdk-php/sdk/Api/SlidesApi.php(14338): Aspose\Slides\Cloud\Sdk\Api\ApiBase->httpCall(Object(GuzzleHttp\Psr7\Request)) #1 /var/www/emi/composer/vendor/aspose/slides-sdk-php/sdk/Api/SlidesApi.php(14322): Aspose\Slides\Cloud\Sdk\Api\SlidesApi->postSlidesConvertWithHttpInfo(Object(Aspose\Slides\Cloud\Sdk\Model\Requests\PostSlidesConvertRequest)) #2 /var/www/emi/aspose/asposeFunctions.php(178): Aspose\Slides\Cloud\Sdk\Api\SlidesApi->postSlidesConvert(Object(Aspose\Slides\Cloud\Sdk\Model\Requests\PostSlidesConvertRequest)) #3 /var/www/emi/aspose/uploadPresentation.php(51): aspConver in /var/www/emi/composer/vendor/aspose/slides-sdk-php/sdk/Api/ApiBase.php on line 84

And here is my request:

Aspose\Slides\Cloud\Sdk\Model\Requests\PostSlidesConvertRequest Object
(
[format] => Pdf
[document] => SplFileObject Object
(
[pathName:SplFileInfo:private] => /tmp/phprna7zS
[fileName:SplFileInfo:private] => phprna7zS
[openMode:SplFileObject:private] => r
[delimiter:SplFileObject:private] => ,
[enclosure:SplFileObject:private] => "
)

[password] => 
[fontsFolder] => 

)

Is there any more information that would be helpful in diagnosing this issue?

@klubar

We are sorry for the confusion. May be it has been changed at the start of API Version V3 launch. Please note you need to use only multipart/form-data content type instead of both application/octet-stream,multipart/form-data in PostSlidesConvert API Method.

curl -X POST "https://api.aspose.cloud/v3.0/slides/convert/Pdf" 
-H "accept: multipart/form-data" 
-H "authorization: Bearer [Access_Token]" 
-H "Content-Type: multipart/form-data" 
-H "x-aspose-client: Containerize.Swagger" 
-F "File=@C:/Temp/KL P3 Pitchbook_FX_FINAL_compressed.pptx" --output C:/Temp/test.pdf

Updating the PHP API from github seems to have fixed the problem. Thanks for the hint!

1 Like