如何在Google API apiclient批量回调中使用request_id

时间:2016-02-14 21:29:02

标签: python google-api google-api-client bulk apiclient

我目前正在使用Google API库apiclient。特别是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吗?我可以自定义价值吗?

1 个答案:

答案 0 :(得分:0)

<div class="row"> <div class="col-lg-4 col-md-4 col-sm-4" style="float:left">Logo </div> <div class="col-lg-4 col-md-4 col-sm-12">Search box</div> <div class="col-lg-4 col-md-4 col-sm-4" style="float:right">Notification icons</div> <div> 是将请求添加到批处理请求时的顺序的整数。它从1开始。

虽然内容是整数,但它存储为字符串。确实很奇怪。