簡體   English   中英

如何提交“無效請求[0] .updateTextStyle:”字段中必須至少列出一個字段。 (使用“ *”表示所有字段。)“>“

[英]How to file 'Invalid requests[0].updateTextStyle: At least one field must be listed in 'fields'. (Use '*' to indicate all fields.)">'

我正在嘗試更新Google文檔,當我嘗試推送更新時,它說googleapiclient.errors.HttpError: <HttpError 400 when requesting https://docs.googleapis.com/v1/documents/1UeorM9adOh8Nds1Z457RRKBZMkh0VZ_kn_jllpkzh7U:batchUpdate?alt=json returned "Invalid requests[0].updateTextStyle: At least one field must be listed in 'fields'. (Use '*' to indicate all fields.)">而且我不知道這是什么意思。

這是引發錯誤的方法

def update(request):
    result = service.documents().batchUpdate(
        documentId=DOCUMENT_ID, body={'requests': [request]}).execute()
    return result

如果有人可以幫助,那就太好了!

這就是我的要求

request = {
  'updateTextStyle': {
    'range': {
      'segmentId': None,
      'startIndex': None, # gets filled with the proper number
      'endIndex': None # gets filled with the proper number
    },
    'textStyle': {
      "bold": False,
      "italic": False,
      "underline": False,
      "strikethrough": False,
      "smallCaps": False,
      "backgroundColor": {
        'color': {
          'rgbColor': {
            'red': 0.2,
            'green': 0.2,
            'blue': 0.2
          }
        }
      },
      "foregroundColor": {
        'color': {
          'rgbColor': {
            'red': 0.96,
            'green': 0.96,
            'blue': 0.96
          }
        }
        },
    "fontSize": {
        'magnitude': 10,
        'unit': 'PT'
    },
  "weightedFontFamily": {
    'fontFamily': 'Courier New OS',
    'weight': 400
  },
  "baselineOffset": 'NONE',
  "link": None
    }
  }
}

At least one field must be listed in 'fields'. (Use '*' to indicate all fields.) At least one field must be listed in 'fields'. (Use '*' to indicate all fields.)表示未在請求正文中設置fields的屬性。 例如,此修改如何?

從:

  },
  "baselineOffset": 'NONE',
  "link": None
    }
  }
}

至:

            },
            "baselineOffset": 'NONE',
            "link": None
        },
        "fields": "*"  # Added
    }
}

注意:

  • 該答案假設您已經能夠使用Google Docs API更新Google文檔。
  • 此修改假定當您使用此請求正文時, None'range': {'segmentId': None, 'startIndex': None, 'endIndex': None},"link": None值都替換為正確的值。

參考:

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM