2

I am building an Android app that programmatically creates a presentation. I've tried using both the Java libraries as well as the online interactive slides API to create a new presentation and set the master slides. I am starting simple here - all I want to do is have a solid blue background master slide. Here is my API call to create:

{
  "title": "test",
  "masters": [
    {
      "pageProperties": {
        "pageBackgroundFill": {
          "solidFill": {
            "color": {
              "rgbColor": {
                "blue": 1.0,
                "green": 0.5,
                "red": 1.0
              }
            }
          }
        }
      },
      "pageType": "MASTER",
      "masterProperties": {
        "displayName": "mymaster"
      },
      "objectId": "mymaster1"
    }
  ]
}

Result is 200 OK. I look at the data in the result and my master is not there. The default master is there however. This is maddening - I have been searching for days on this. I must be missing some required fields - but this is not documented well by Google. I'd greatly appreciate some guidance on this.

Here is my Java code:

// Build master -
        List<Page> master = new ArrayList<>();
        master.add(new Page().setPageProperties(new PageProperties().setPageBackgroundFill(new PageBackgroundFill()
                .setSolidFill(new SolidFill().setColor(new OpaqueColor()
                .setRgbColor(new RgbColor().setRed(1.0f).setGreen(0.5f).setBlue(1.0f))))))
                                        .setPageType("MASTER").setObjectId("mymaster1").setMasterProperties(new MasterProperties().setDisplayName("mymaster")));

        // Create presentation
        Presentation presentation = new Presentation()
                .setTitle("test").setMasters(master);
        presentation = mSlidesService.presentations().create(presentation)
                .setFields("presentationId")
                .execute();

1 Answers1

0

The official documentation is misleading, showing all the fields in the request body.

It says:

If a presentationId is provided, it is used as the ID of the new presentation. Otherwise, a new ID is generated. Other fields in the request, including any provided content, are ignored. Returns the created presentation.

So, only the title and the presentationId are used. Use batchUpdate() right after creation of the presentation.

https://developers.google.com/slides/api/reference/rest/v1/presentations/create

Kostiantyn
  • 1,792
  • 2
  • 16
  • 21