Aspose.Slides Cloud for PHP 22.2 Returns 404 on createChartSeries

Hi,
We’re facing issues when calling your api in order to add a chart series:

$dto = new OneValueSeries();
$dataPoints = [];
foreach ($values as $value) {
    $dataPoint = new OneValueChartDataPoint();
    $dataPoint->setValue($value);
    $dataPoints[] = $dataPoint;
}
$dto->setDataPoints($dataPoints);

$result = $this->api()->createChartSeries($file_name, $slideIndex, $chartIndex, $dto);

The following is returned

{
  "message": "[404] Client error: `POST https://api.aspose.cloud/v3.0/slides/4c0cece9-83eb-4283-a412-7afddeecccb2_534dc3e0f2e77d9d694b0b5fd0d3bcbe.pptx/slides/2/shapes/series` resulted in a `404 Not Found` response",
  "exception": "Aspose\\Slides\\Cloud\\Sdk\\Api\\ApiException",
  "file": "/var/www/html/vendor/aspose/slides-sdk-php/sdk/Api/ApiBase.php",
  "line": 89,
  "trace": [
    {
      "file": "/var/www/html/vendor/aspose/slides-sdk-php/sdk/Api/SlidesApi.php",
      "line": 2486,
      "function": "httpCall",
      "class": "Aspose\\Slides\\Cloud\\Sdk\\Api\\ApiBase",
      "type": "->"
    },
    {
      "file": "/var/www/html/vendor/aspose/slides-sdk-php/sdk/Api/SlidesApi.php",
      "line": 2470,
      "function": "createChartSeriesWithHttpInfo",
      "class": "Aspose\\Slides\\Cloud\\Sdk\\Api\\SlidesApi",
      "type": "->"
    },
...

@UNulrikhjarnaa,
Thank you for contacting support.

I was able to reproduce a similar error when the presentation file does not exist. Please check if the file $file_name exists in your default storage.

Thanks for your prompt response. I can confirm that the file exists as expected.
image.png (9.2 KB)

image.png (5.6 KB)

@UNulrikhjarnaa,
Thank you for the additional data. The code example you provided contains unknown variables ($values, for example). To check the error on our side, please share the following:

  • presentation file
  • comprehensive code example

code: createChartSeries · GitHub
file: https://filebin.net/tgroei6wb1fbn48s

@UNulrikhjarnaa,
In Aspose.Slides Cloud API, object indexes start at 1 (slide index, shape index, etc.). Please correct your code depending on which the chart you want to change. This should help.

Documents: Add Chart Series
API Reference: CreateChartSeries

Hi Andrey,
It seems your documentation is not fully updated nor tested and missing key information.
Why does the createChartSeries method expect the $series argument to be of type \Aspose\Slides\Cloud\Sdk\Model\Series (link) when the documentation states it has to be of type Aspose\Slides\Cloud\Sdk\Model\OneValueSeries?
Furthermore, the Series model doesn’t support adding items/datapoints.
Also, in relation to my question asked elsewhere, how are you supposed to add a Series to an index if you’re not able to get the existing chart index of a slide. In other words, there’s no way to retrieve a chart from a slide, like, say, getChartSeries() or getSlideCharts()
Thanks again.

@UNulrikhjarnaa,
We apologize for any inconvenience. The documentation will be updated later.

The series type depends on a chart type used. The Series class is base class for other series classes. To add data points to charts, you should use appropriate series.

You can know the shape index of a chart as shown below:

$fileName = "dddd.pptx";

$slidesInfo = $slidesApi->getSlides($fileName);
$slideCount = count($slidesInfo->getSlideList());

for ($slideIndex = 1; $slideIndex <= $slideCount; $slideIndex++)
{
    $shapesInfo = $slidesApi->getShapes($fileName, $slideIndex);
    $shapeCount = count($shapesInfo->getShapesLinks());

    for ($shapeIndex = 1; $shapeIndex <= $shapeCount; $shapeIndex++)
    {
        $shape = $slidesApi->getShape($fileName, $slideIndex, $shapeIndex);
        if ($shape->getType() == "Chart")
        {
            echo "A chart was found. Slide index: ", $slideIndex, ", shape index: ", $shapeIndex, "\r\n";
        }
    }
}

Output:

A chart was found. Slide index: 2, shape index: 4
A chart was found. Slide index: 3, shape index: 2
A chart was found. Slide index: 3, shape index: 3

You can use these shape indices to access the charts.

I think it is a good idea to get all charts on a slide at once. I’ve added a ticket with ID SLIDESCLOUD-1411 to our issue tracking system. Our development team will consider implementing this feature. You will be notified when the issue is resolved.

The issues you have found earlier (filed as SLIDESCLOUD-1411) have been fixed in Aspose.Slides Cloud 22.3. You can check all fixes on the Release Notes page.

@UNulrikhjarnaa,
The following code snippet shows you how to get all charts from the first slide, for example:

use Aspose\Slides\Cloud\Sdk\Api\Configuration;
use Aspose\Slides\Cloud\Sdk\Api\SlidesApi;
use Aspose\Slides\Cloud\Sdk\Model\ShapeType;

//...

$charts = $slidesApi->getShapes(
    "MyPresentation.pptx", 1, null, null, null, ShapeType::CHART); 

print(count($charts->getShapesLinks()));

Documents: Extract Shapes from a Slide