[英]How To Use request_id in Google API apiclient batch callback
我目前正在使用apiclient
,Google API庫。 特別是python之一。 該文檔確實不清楚。 我不知道如何利用從回調獲得的request_id
。 我的意思是這段代碼:
from apiclient.http import BatchHttpRequest
def insert_animal(request_id, response, exception):
if exception is not None:
# Do something with the exception
pass
else:
# Do something with the response
pass
service = build('farm', 'v2')
batch = service.new_batch_http_request(callback=insert_animal)
batch.add(service.animals().insert(name="sheep"))
batch.add(service.animals().insert(name="pig"))
batch.add(service.animals().insert(name="llama"))
batch.execute(http=http)
有人可以解釋request_id
嗎? 我可以自定義值嗎?
request_id
是將請求添加到批處理請求中的順序的整數。 從1開始。
盡管內容是整數,但仍存儲為字符串。 確實很奇怪。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.