Reputation: 139
How do I create an Red Rectangle with the Google Slides API? The following code is not working:
var requests = [{
createShape: {
objectId: elementId,
shapeType: 'RECTANGLE',
shapeProperties: {
shapeBackgroundFill: {
solidFill: {
color: {
"themeColor": "Red"
}
}
}
},
elementProperties: {
pageObjectId: 'gc448bf14e8_0_0',
size: {
height: pt150,
width: pt150
},
transform: {
scaleX: 1,
scaleY: 1,
translateX: 150,
translateY: 100,
unit: 'PT'
}
}
}
},
GoogleJsonResponseException: API call to slides.presentations.batchUpdate failed with error: Invalid JSON payload received. Unknown name "shapeProperties" at 'requests[0].create_shape': Cannot find field.
This resource wants to Change the shape, I want to put it into original request object. Change background of google slides shape to red
Looking at this Google Resource: https://developers.google.com/slides/reference/rest/v1/presentations.pages/shapes
Upvotes: 2
Views: 300
Reputation: 1414
PHP version for updating the object background colour and border colour.
$requests[] = new \Google_Service_Slides_Request([
'updateShapeProperties' => [
'objectId' => $objectId,
'fields' => 'shapeBackgroundFill.solidFill.color, outline.outlineFill.solidFill.color',
'shapeProperties' => [
'shapeBackgroundFill' => [
'solidFill' => [
'color' => [
'rgbColor' => [
'red' => $elementOption['colour']['red']/255,
'green' => $elementOption['colour']['green']/255,
'blue' => $elementOption['colour']['blue']/255
]
]
]
],
'outline' => [
'outlineFill' => [
'solidFill' => [
'color' => [
'rgbColor' => [
'red' => $elementOption['colour']['red']/255,
'green' => $elementOption['colour']['green']/255,
'blue' => $elementOption['colour']['blue']/255
]
]
]
]
]
]
]
]);
Upvotes: 0
Reputation: 139
Currently the API for createshaperequest
does not have shapeProperties. Only updateShapeProperties
has it.
I made two requests,
var requests2 = [{
updateShapeProperties: {
objectId: elementId,
fields: "shapeBackgroundFill.solidFill.color",
shapeProperties: {
shapeBackgroundFill: {
solidFill: {
color: {
rgbColor:
{
red: 0.6,
green: 0.0,
blue: 0.0
}
}
}
}
}
}
}];
https://developers.google.com/slides/reference/rest/v1/presentations/request#createshaperequest
Upvotes: 3