PHP error running the Words API Batch Tests

I am running the BatchTests::testBatch function from the tests/Aspose/Words/BatchTests.php file.

As far as I can tell the Batch request is working - the TestGetDocumentParagraphByIndexBatch.docx document is created and the API log in my dashboard doesn’t show any errors.

However the call is reporting the following error:

Undefined property: stdClass::$Error {"exception":"[object] (ErrorException(code: 0): Undefined property: stdClass::$Error at /laravel/vendor/aspose-cloud/aspose-words-cloud/src/Aspose/Words/ApiException.php:93)
[stacktrace]
#0 /laravel/vendor/laravel/framework/src/Illuminate/Foundation/Bootstrap/HandleExceptions.php(266): Illuminate\\Foundation\\Bootstrap\\HandleExceptions->handleError()
#1 /laravel/vendor/aspose-cloud/aspose-words-cloud/src/Aspose/Words/ApiException.php(93): Illuminate\\Foundation\\Bootstrap\\HandleExceptions->Illuminate\\Foundation\\Bootstrap\\{closure}()
#2 /laravel/vendor/aspose-cloud/aspose-words-cloud/src/Aspose/Words/ObjectSerializer.php(229): Aspose\\Words\\ApiException->__construct()
#3 /laravel/vendor/aspose-cloud/aspose-words-cloud/src/Aspose/Words/ObjectSerializer.php(287): Aspose\\Words\\ObjectSerializer::parseSinglePart()
#4 /laravel/vendor/aspose-cloud/aspose-words-cloud/src/Aspose/Words/WordsApi.php(53765): Aspose\\Words\\ObjectSerializer::parseBatchResponse()
#5 /laravel/vendor/guzzlehttp/promises/src/Promise.php(204): Aspose\\Words\\WordsApi->Aspose\\Words\\{closure}()
#6 /laravel/vendor/guzzlehttp/promises/src/Promise.php(153): GuzzleHttp\\Promise\\Promise::callHandler()
#7 /laravel/vendor/guzzlehttp/promises/src/TaskQueue.php(48): GuzzleHttp\\Promise\\Promise::GuzzleHttp\\Promise\\{closure}()
#8 /laravel/vendor/guzzlehttp/guzzle/src/Handler/CurlMultiHandler.php(159): GuzzleHttp\\Promise\\TaskQueue->run()
#9 /laravel/vendor/guzzlehttp/guzzle/src/Handler/CurlMultiHandler.php(184): GuzzleHttp\\Handler\\CurlMultiHandler->tick()
#10 /laravel/vendor/guzzlehttp/promises/src/Promise.php(248): GuzzleHttp\\Handler\\CurlMultiHandler->execute()
#11 /laravel/vendor/guzzlehttp/promises/src/Promise.php(224): GuzzleHttp\\Promise\\Promise->invokeWaitFn()
#12 /laravel/vendor/guzzlehttp/promises/src/Promise.php(269): GuzzleHttp\\Promise\\Promise->waitIfPending()
#13 /laravel/vendor/guzzlehttp/promises/src/Promise.php(226): GuzzleHttp\\Promise\\Promise->invokeWaitList()
#14 /laravel/vendor/guzzlehttp/promises/src/Promise.php(62): GuzzleHttp\\Promise\\Promise->waitIfPending()
#15 /laravel/vendor/aspose-cloud/aspose-words-cloud/src/Aspose/Words/WordsApi.php(53641): GuzzleHttp\\Promise\\Promise->wait()
#16 /laravel/vendor/aspose-cloud/aspose-words-cloud/src/Aspose/Words/WordsApi.php(53622): Aspose\\Words\\WordsApi->batchWithHttpInfo()

It looks like the response body doesn’t have an error property - which explains why the API log isn’t showing any errors. However the status code returned cannot have been 200 or an exception wouldn’t have been thrown.

Can you reproduce this?

@FFSPUD

We are trying to replicate the issue for investigation and will share our findings with you soon.

@FFSPUD

We have fixed batch request processing in the latest release. We will appreciate it if you please double check and share the results.

Hello

The batch request is working now - thank you, however either the $displayIntermediateResults parameter is not working or the setParentRequestId() function is not working.

If I change the last few lines of code in the test case to:

        $request6 = new Requests\BatchPartRequest(
                            new SearchRequest(
                                $name=$remoteName,
                                "new",
                                $folder=self::$baseRemoteFolderPath . $subfolder
                    ));        
        $request6->setParentRequestId($request3);

        $upload_result = self::wordsApi()->uploadFile($request0);

        $result = self::wordsApi()->batch(array($request1, $request2, $request3, $request4, $request5, $request6));

Then I get the following reponse:

[[{"Aspose\\Words\\Model\\ParagraphLinkCollectionResponse":"{}"},{"Aspose\\Words\\Model\\ParagraphResponse":"{}"},{"Aspose\\Words\\Model\\ParagraphResponse":"{}"},{"Aspose\\Words\\Model\\SearchResponse":"{}"},null,{"SplFileObject":"PK\u0003\u0004\u0014\u0000\u0000\u0000\b\u0000\u0016g�V\u0017���Q\u0001\u0000\u0000(\u0005\u0000\u0000\u0013\u0000\u0000\u0000[Content_Types].xml��MN�0\u0010F�by�\u0012�,\u0010BM�\u0000�P�^��'��c[���LR\u001aPU�\u0016�&R23�{\u001e%\u0019�7�e+��xW�a>�\f��ڸy��Xe��%�NK�\u001d\u0014|\u000b����t\u001b 1�u��\u000b�� DR\u000b�e�}\u0000G���Z\"�ƹ\bR��9���N(�\u0010\u001cf�d�r�\u0004�\\Zd�\u001bz��`\u0013g��ƆUp\u0019�5J\"����\u0003J�I�i��I\u000b\u0013�\r5p&�\"�ҏ���+�&\u001a\rl\"#�Țڄ�j\u0012}H�\u0006��1GD}U\u0019\u0005���i$��H��\u0002EBD\u0003_�'��G���_S3}.r�\u0016���ȃ\u00037i\u0004V�\u0012�c�ͻJ-��\u0017�\b=�3����t�\u0016\t\u0010i(���>�\f\u0007�Z��A���G��aw\u001d�٢��g�a�v��\u000b�LD��+?\u0000PK\u0003\u0004\u0014\u0000\u0000\u0000\b\u0000\u0016g�V+\ffW�\u0000\u0000\u0000O\u0002\u0000\u0000\u000b\u0000\u0000\u0000_rels/.rels���J\u0003A\f�_eȽ�m\u0005\u0011�\u0017/���\u0002a&�;���L���\u001bA��Zz�/\u001f!��!��k\u000b9YXv=\u0018N.��F\u000b{\u0019\u0016\u000f`�P�4��\u0016��`�Y��L�#m\n"}]] 

Either the intermediate results for SearchResponse aren’t being collected - or the API call is running in parallel before request3 has had a chance to run - in which case the setParentRequestId isn’t being processed.

Becuase the other intermediate results are also empty I suspect that the results aren’t being collected.

@FFSPUD

Kindly share your sample code along with the input document(s). It will help us investigate and guide you exactly.

Here is the code (it’s based on the testBatch function in vendor/aspose-cloud/aspose-words-cloud/tests/Aspose/Words/BatchTests.php).

The files used are the same ones in the latest composer package.

        $localName = "test_multi_pages.docx";
        $remoteName = "TestGetDocumentParagraphByIndexBatch-".(time() - strtotime("today")).".docx";
        $subfolder = "";
        $fullName = self::$baseRemoteFolderPath . $subfolder . "/" . $remoteName;
        $intermediateResults = true;

        $file = realpath(base_path() . '/vendor/aspose-cloud/aspose-words-cloud/TestData/Common/' . $localName);
        $request0 = new Requests\UploadFileRequest($file, $fullName);

        $request1 = new Requests\BatchPartRequest(new Requests\GetParagraphsRequest($name=$remoteName, $nodePath="sections/0", $folder=self::$baseRemoteFolderPath . $subfolder));

        $request2 = new Requests\BatchPartRequest(new Requests\GetParagraphRequest($name=$remoteName, $index=0, $nodePath="sections/0", $folder=self::$baseRemoteFolderPath . $subfolder));

        $request3Body = new \Aspose\Words\Model\ParagraphInsert(array(
            "text" => "This is a new paragraph for your document",
        ));

        $request3 = new Requests\BatchPartRequest(new Requests\InsertParagraphRequest($name=$remoteName, $paragraph=$request3Body, $nodePath="sections/0", $folder=self::$baseRemoteFolderPath . $subfolder));

        $request4 = new Requests\BatchPartRequest(new Requests\DeleteParagraphRequest($name=$remoteName, $index=0, $nodePath="sections/0", $folder=self::$baseRemoteFolderPath . $subfolder));

        $reportingFolder = "DocumentActions/Reporting";
        $localDocumentFile = "ReportTemplate.docx";

        $localDataFile = file_get_contents(realpath(base_path() . '/vendor/aspose-cloud/aspose-words-cloud/TestData/' . $reportingFolder . "/ReportData.json"));

        $requestReportEngineSettings = new \Aspose\Words\Model\ReportEngineSettings(array(
            "data_source_type" => "Json",
            "data_source_name" => "persons",
        ));
        $buildRequest = new Requests\BuildReportOnlineRequest(
            realpath(base_path() . '/vendor/aspose-cloud/aspose-words-cloud/TestData/' . $reportingFolder . "/" . $localDocumentFile),
            $localDataFile,
            $requestReportEngineSettings,
            NULL
        );
        $request5 = new Requests\BatchPartRequest($buildRequest);

        $request6 = new Requests\BatchPartRequest(
                            new SearchRequest(
                                $name=$remoteName,
                                "new",
                                $folder=self::$baseRemoteFolderPath . $subfolder
                    ));        
        $request6->setParentRequestId($request3);

        $upload_result = $wordsApi->uploadFile($request0);

        $result = $wordsApi->batch(array($request1, $request2, $request3, $request4, $request5, $request6), $intermediateResults);

@FFSPUD
We have opened the following new ticket(s) in our internal issue tracking system and will deliver their fixes according to the terms mentioned in Free Support Policies.

Issue ID(s): WORDSCLOUD-2343

You can obtain Paid Support Services if you need support on a priority basis, along with the direct access to our Paid Support management team.

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