Обновление цвета фигуры с помощью Ruby Google Slides API

Я пытаюсь обновить форму многоточия с помощью API слайдов Google в рубине. Это код:

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)

Еще один код, который я пробовал с той же ошибкой, - это:

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)

Я получаю такую ​​ошибку:

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

Есть идеи, почему это не удается?


person jordiPons    schedule 18.05.2018    source источник
comment
Не удалось найти объект (). похоже, что вы не отправляете объект   -  person DaImTo    schedule 18.05.2018
comment
@DaImTo Я обновил сообщение еще одной попыткой, которую я сделал, чтобы убедиться, что отправляю объект, но у меня была та же ошибка   -  person jordiPons    schedule 18.05.2018


Ответы (1)


попробуйте использовать object_id_prop вместо object_id в 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)

Поскольку UpdateShapePropertiesRequest имеет object_id_prop вместо object_id. Вот почему имя object_id уже используется в Объект.

person Koya Fukushi    schedule 07.11.2018