Free Support Forum -

PHP SDK MailMerge 500s and File Upload 400s

Hi Aspose Team,

We seem to be hitting intermittent 500 errors with MailMerge requests and consistent 400 errors when trying to upload files to cloud storage to then be converted.

A 500 issue with the PHP SDK was recently fixed ([500] Error connecting to the API) and we are wondering if it was perhaps not fully resolved?

Equally, we can’t seem to upload files to cloud storage at all be it your own storage servers or other services. We use the PHP SDK to execute our requests and use the following code:

$this->wordsApi->uploadFile(new Requests\UploadFileRequest($file, "", null));

Please let us know if there is anything we can do to rectify these issues.

We look forward to your reply.


We are sorry for the inconvenience. I just checked the Upload and MailMerge API with Aspose.Words Cloud SDK for PHP and unable to replicate the issue. We will appreciate it if you please share your sample code along with the PHP SDK version. We will investigate the issue and guide you.

$templateName = "SampleMailMergeTemplate.docx";
$outputName = "ExecuteMailMerge_output.docx";
#read mailmerge data
$data = file_get_contents("SampleMailMergeTemplateData.txt");
##upload template file to storage
$uploadRequest = new Aspose\Words\Model\Requests\UploadFileRequest($templateName, $templateName,null);
##Execute MailMerge
$request = new Aspose\Words\Model\Requests\ExecuteMailMergeRequest($templateName, $data, null,null, null, null, null,null, null, false, $outputName);
$result = $wordsApi->executeMailMerge($request);

Hi @tilal.ahmad

I’ve just tried your example substituting for the relevant files and I get a 400 error every time. It’s worth noting we prefer to use the executeMailMergeOnline request.

It’s also worth noting that our code hasn’t changed and we were getting successful requests last week but today we have been unable to perform conversions from docx to pdf.

We use composer for the install so it should be using the latest version of the SDK:

 "require": {
	    "aspose-cloud/aspose-words-cloud" : "*"

We also implemented a solution using cURL and infrequently get http errors that just hang which matches the intermittent 500 error which we were getting with the PHP SDK.

< content-type: application/json; charset=utf-8
< server: Kestrel
* HTTP error before end of send, stop sending

This error seems to relate to the file upload:

    "Error": {
    "Message": "Could not find file 'C:\\Users\\ContainerAdministrator\\AppData\\Local\\Temp\\ASPNETCORE_c1a26600-eaac-4d08-b02e-f30de42007a9.tmp'."


It is quite a strange issue. We have logged an investigation ticket (WORDSCLOUD-1390). We keep you updated about the issue resolution progress within this thread.

1 Like

Thanks @tilal.ahmad


Please note the second parameter in UploadFileRequest API method is the cloud storage path including file name and folder where to upload a file. I noticed that when we pass an empty value against the parameter API throws a 500 error, otherwise works fine. Please verify it at your end. However, if you still face the issue, then kindly share your complete MailMerge sample code here with us to replicate the issue.