I'm trying to delete a slide from a presentation I have on google drive. Currently authentication works and I am able to retrieve the presentation and get the slide id I want to delete from there. When I send the request to delete the slide it throws this error:
Caught error badRequest: Invalid requests[0]: No request set.
Here is how I am formatting my request
requests = [{
requests: {
delete_object:
{
object_id: '<slide_id_goes_here>'
}
}
}]
Here is how I am sending the request to the API
service = authorize_service(Google::Apis::SlidesV1::SlidesService.new, scopes)
req = Google::Apis::SlidesV1::BatchUpdatePresentationRequest.new(requests: requests)
service.batch_update_presentation(presentation_id, req, {})
What is causing this error? How should I be formatting this in ruby?
Edit:
To get the slide id that I want to delete I take this type of object
Google::Apis::SlidesV1::Presentation
and then call
google_slides_api_presentation_object.slides.first.object_id
Maybe this is part of my problem?
How about this modification?
delete_object = Google::Apis::SlidesV1::DeleteObjectRequest.new()
delete_object.object_id_prop = "<slide_id_goes_here>"
request = Google::Apis::SlidesV1::Request.new(delete_object: delete_object)
requests = Array.new([request])
batch = Google::Apis::SlidesV1::BatchUpdatePresentationRequest.new(requests: [])
batch.update!(requests: requests)
res = service.batch_update_presentation(presentation_id, batch, {})