Search code examples
google-slides-api

Google Slide API script updateShapeProperties autofit


Getting error "GoogleJsonResponseException: API call to slides.presentations.batchUpdate failed with error: Invalid requests[3].updateShapeProperties: Invalid field: autofit_type"

but I think my code is right:

'updateShapeProperties': {
  'objectId': pageElementId,
    'fields': 'autofitType',
    'shapeProperties': {
    'autofit': {
      'autofitType':'SHAPE_AUTOFIT'
    }
  }
}

Any help much appreciated Cheers Greg


Solution

  • I thought that the error message means that the value of fields is not correct. In your script, how about modifying as follows.

    From:

    'fields': 'autofitType',
    

    To:

    'fields': 'autofit.autofitType',
    

    Note:

    • But, in the current stage, it seems that the value of autofitType can only use NONE. So, when SHAPE_AUTOFIT and TEXT_AUTOFIT is used for autofitType, an error of Autofit types other than NONE are not supported. occurs. Please be careful this.
      • About this, it seems that this is not reported as the future request in the issue tracker. So how about reporting it as the future request? Ref
    • When you test above modification, please modify 'autofitType':'SHAPE_AUTOFIT' to 'autofitType':'NONE'. By this, the request occurs no error.

    Reference: