How to pass body with Google APIs Client Library?

徘徊边缘 提交于 2019-12-12 01:31:26

问题


I use Google APIs Client Library for Python to work with Fusion Tables API. importRows method here requires to provide the data in the body. How should I do it?

response = service.table().importRows(tableId=TABLE_ID, body='zzz,yyy').execute()

returns the error - Got an unexpected keyword argument "body".


回答1:


There's a slight subtlety here -- the body of the request should be the Table resource, if you want to update it; the contents (in this case, the rows) should actually be passed as a media upload.

In the python client, this means you want to pass something in to the media_body argument, not body. You can't just pass a literal string -- you need to wrap the data in either a MediaFileUpload or MediaInMemoryUpload. (For the case here, you want the latter, but if you've got a file with rows on disk, you want the former.)



来源:https://stackoverflow.com/questions/23801255/how-to-pass-body-with-google-apis-client-library

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!