0

I'm trying to update an ellipsis shape using the google slides api in ruby. This is the code:

shape_properties = {
    shape_background_fill: {
        solid_fill: {
            color: {
                rgb_color: {
                    red: 1.0,
                    green: 0,
                    blue: 0
                }
            }
        }
    }
}

requests = [{
              update_shape_properties: {
                object_id: ellipse.object_id,
                fields: 'shapeBackgroundFill',
                shape_properties: shape_properties,
              },
            }]

# Execute the request.
req = Google::Apis::SlidesV1::BatchUpdatePresentationRequest.new(requests: requests)
response = @slides.batch_update_presentation(presentation_id,req)

Another code that I've tried with the same error is this one:

rgb_color = Google::Apis::SlidesV1::RgbColor.new(red: 1.0, green: 0, blue: 0)
color = Google::Apis::SlidesV1::OpaqueColor.new(rgb_color: rgb_color)
solid_fill = Google::Apis::SlidesV1::SolidFill.new(color: color)
shape_background_fill = Google::Apis::SlidesV1::ShapeBackgroundFill.new(solid_fill: solid_fill)
shape_properties = Google::Apis::SlidesV1::ShapeProperties.new(shape_background_fill: shape_background_fill)
requests = [{
                update_shape_properties: {
                  object_id: ellipse.object_id,
                  fields: 'shapeBackgroundFill',
                  shape_properties: shape_properties,
                },
            }]
req = Google::Apis::SlidesV1::BatchUpdatePresentationRequest.new(requests: requests)
response = @slides.batch_update_presentation(presentation_id, req)

I get this error:

`check_status': badRequest: Invalid requests[0].updateShapeProperties: The object () could not be found. (Google::Apis::ClientError)

Any idea why is it fails?

jordiPons
  • 164
  • 5
  • 21

1 Answers1

0

try using object_id_prop instead of object_id in update_shape_properties.

shape_properties = {
    shape_background_fill: {
        solid_fill: {
            color: {
                rgb_color: {
                    red: 1.0,
                    green: 0,
                    blue: 0
                }
            }
        }
    }
}

requests = [{
          update_shape_properties: {
            object_id_prop: ellipse.object_id,
            fields: 'shapeBackgroundFill',
            shape_properties: shape_properties,
          },
        }]

# Execute the request.
req = Google::Apis::SlidesV1::BatchUpdatePresentationRequest.new(requests: 
requests)
response = @slides.batch_update_presentation(pres`entation_id,req)

Because UpdateShapePropertiesRequest has object_id_prop accessor instead of object_id. That's why object_id name is already used in Object.