Skip to content

Instantly share code, notes, and snippets.

@seinecle
Created February 25, 2019 09:00
Show Gist options
  • Save seinecle/922951a4807f5024f4278d576d56f60c to your computer and use it in GitHub Desktop.
Save seinecle/922951a4807f5024f4278d576d56f60c to your computer and use it in GitHub Desktop.
How to create and edit a Google Slide via the Java API client
// login and credentials steps are skipped
// because it is such a mess
// I found no example anywhere of how to build and edit a new Google Slides presentation via the Java API client.
// So here you go: how to create two empty slides.
Presentation prezTemp = new Presentation();
prezTemp.setTitle("test_" + String.valueOf(Math.random()));
prez = googleSlides.presentations().create(prezTemp).execute();
BatchUpdatePresentationRequest update = new BatchUpdatePresentationRequest();
Request request = new Request();
Request request1 = new Request();
CreateSlideRequest slide = new CreateSlideRequest();
request.setCreateSlide(slide);
request1.setCreateSlide(slide);
List<Request> requests = new ArrayList();
requests.add(request);
requests.add(request1);
update.setRequests(requests);
googleSlides.presentations().batchUpdate(prez.getPresentationId(), update).execute();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment