当我运行以下代码时,我收到此错误。
{'error': {'code': 400, 'message': '收到无效的 JSON 有效负载。未知名称“album_id”:原始字段不重复,无法启动列表。','status':'INVALID_ARGUMENT','details':[{'@type':'type.googleapis.com/google.rpc.BadRequest' , 'fieldViolations': [{'description': '接收到无效的 JSON 有效负载。未知名称“album_id”:原始字段不重复,无法启动列表。'}]}]}}
如果我删除 "albumId": ["albumid code"] 它工作正常并返回
10个新项目,共10个
def _actually_list_media_items(session):
ret = []
params = {
'fields': 'mediaItems(id,baseUrl,filename,mimeType,productUrl),nextPageToken',
}
search_json = {
"pageSize": 10,
"albumId": ["<albumid code>"],
"filters": {
"includeArchivedMedia": False,
"contentFilter": {
"excludedContentCategories": [
"DOCUMENTS",
"RECEIPTS",
"SCREENSHOTS",
"UTILITY",
"WHITEBOARDS",
]
},
"mediaTypeFilter": {
"mediaTypes": [
"PHOTO",
],
},
},
}
tmp = 0
while tmp < 1:
rsp = session.post(
'https://photoslibrary.googleapis.com/v1/mediaItems:search',
params=params,
json=search_json,
).json()
if 'error' in rsp:
print(rsp)
cur = [m for m in rsp.get('mediaItems', [])]
ret += cur
print(f'{len(cur)} new items, total {len(ret)}')
pageToken = rsp.get('nextPageToken')
if pageToken is None:
break
params['pageToken'] = pageToken
tmp = tmp + 1
return ret