PHP Mail Merge API request in Aspose.Words REST API throws 500 Error

@infolemadk

We are sorry for the inconvenience. We have reproduced the issue and logged a ticket WORDSCLOUD-1363 for further investigation and resolution. We will notify you as soon as it is resolved.

Hi there @tilal.ahmad ,

Is there anywhere we can track the progress of WORDSCLOUD-1363?

Getting a similar issue with the mail merge API: [500] Error connecting to the API (https://api.aspose.cloud/v4.0/words/MailMerge).

Thanks in advance.

@Unity5

You can check the status from the following issues status window in this thread or can ask us for the update.

Can you please share how you are calling the MailMerge API, using Aspose.Words Cloud SDK for PHP? As we noticed that the issue is only happening with PHP SDK.

Thank you for your reply @tilal.ahmad

To build the basis of our api calls we use:
$this->wordsApi = new WordsApi(ASPOSE_ID, ASPOSE_KEY);

Then to execute requests we use calls similar to:
$this->wordsApi->executeMailMergeOnline($request);

This code was known to be working last week and stopped working yesterday.

Look forward to hearing your suggestions.

@Unity5

Thanks for your feedback. We are updating our Aspose.Words Cloud SDK for PHP and hopefully will share it shortly.

Please can we get an update ASAP, parts of our system are essentially down as a result of this as it has been going on for days.

Kind regards,

@infolemadk, @Unity5

Thanks for your patience and cooperation. We have fixed the issue, it should work now. Please check and confirm.

1 Like

@tilal.ahmad can confirm that our tests for mail merge via the API are now working.

Thanks for the update!

1 Like

@tilal.ahmad I can confirm that the problem has been fixed now. Thanks.

2 Likes

The issues you have found earlier (filed as WORDSCLOUD-1363) have been fixed in this update. This message was posted using Bugs notification tool by tilal.ahmad

@tilal.ahmad @aspose we started to face this issue again today. Can you please check on your side? Thanks.

1 Like

@infolemadk

We will appreciate it if you please check it again, it should be working now as expected. We were deploying the new version of Aspose.Words Cloud API, that caused the issue.

@tilal.ahmad we have tried again but we are still facing the same issue.

@infolemadk

I have tested again with the latest PHP SDK 21.1 of Aspose.Words Cloud and unable to replicate the issue. We will appreciate it if you please upgrade to the latest SDK version of Aspose.Words Cloud SDK for PHP, it will resolve the issue at your end. We are truly sorry for the inconvenience caused.

I am using version 22.12.0 of the PHP api, getting Error connecting to the API when calling ExecuteMailMerge. Using PHP version 8.1

Regarding the above, the error reported was: Client error: POST https://api.aspose.cloud/connect/token resulted in a 400 Bad Request response:
{“error”:“invalid_client”}
Note I upgraded to a paid account to see if this was the problem, still getting the same results.

@djamesfar

I have tested the ExecuteMailMerge API method with my sample template and data, but have been unable to notice any issues. Please review the following sample code. If the issue persists, then please share your sample code along with your credentials via a private message. We will investigate the issue and guide you. For a private message, click on my user icon and use the message option for it.

<?php

require_once('D:\xampp\htdocs\aspose-words-cloud-php-master\vendor\autoload.php');

//TODO: Get your ClientID and ClientSecret at https://dashboard.aspose.cloud (free registration is required).

$ClientId="xxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx";
$ClientSecret="xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx";

$wordsApi = new Aspose\Words\WordsApi($ClientId,$ClientSecret);

try {
		
$templateName = "template.docx";
$outputName = "ExecuteMailMerge_output.docx";
$remoteFolder="Temp";
#read mailmerge data
$data = file_get_contents("data_file.xml");

$fieldOptions= new Aspose\Words\Model\FieldOptions([
'field_update_culture_name'=>'de-DE', 'field_update_culture_source'=>Aspose\Words\Model\FieldOptions::FIELD_UPDATE_CULTURE_SOURCE_FIELD_CODE]);

##upload template file to storage
$uploadRequest = new Aspose\Words\Model\Requests\UploadFileRequest($templateName,$remoteFolder."/".$templateName,null);
$wordsApi->uploadFile($uploadRequest);

##Execute MailMerge
$request = new Aspose\Words\Model\Requests\ExecuteMailMergeRequest($templateName, $data,$fieldOptions, $remoteFolder,NULL,NULL,NULL,NULL,false,NULL,NULL,NULL, $remoteFolder."/".$outputName);
$result = $wordsApi->executeMailMerge($request);
		
##Download file 
$request = new Aspose\Words\Model\Requests\DownloadFileRequest($remoteFolder."/".$outputName,NULL,NULL);
$result = $wordsApi->downloadFile($request);
copy($result->getPathName(),"MailMerge_output.docx");
print_r($result);
    
    
} catch (Exception $e) {
    echo  "Something went wrong: ",  $e->getMessage(), "\n";
    PHP_EOL;
}

?>

Hello and thanks for the reply. I appreciate the sample code, but it does not appear it’s even getting past the new WordsApi() call - it is failing with “invalid client” in the response message.

Thanks,
DJ

I posted my creds in a message to you by clicking on your user icon, but it appeared to show in the public thread, so I removed them. Please advise on how to send them to you in a DM

@djamesfar

It will work. If you have any concern, you can send a test message. Please check the following thread for details.