1

I'm using the apiclient.discovery.build to lease tasks from a Google Pull Queue.. It's working fine.. But when I try to insert tasks in this Queue, I always get the same error:

from apiclient.discovery import build
build = build('taskqueue', 'v1beta2', credentials=GoogleCredentials.get_application_default())

# Works
resp = build.tasks().lease(project=project,taskqueue=name,leaseSecs=lease_time,numTasks=num_tasks).execute()

# Error
payload = {'payloadBase64': 'c29tZSB0ZXN0'}
result = build.tasks().insert(project=project,taskqueue=name,body=payload)

raise HttpError(resp, content, uri=self.uri) googleapiclient.errors.HttpError: https://www.googleapis.com/taskqueue/v1beta2/projects/project_test/taskqueues/pullqq/tasks?alt=json returned "Backend Error">

The authentication is correct because I can lease/delete tasks.. It might be some missing field in the payload?

rriccilopes
  • 399
  • 2
  • 10

1 Answers1

1

Well.. I changed the payload with the exactly payload from the leased tasks.. except for some fields (e.g., ID or leasing time) and added the '~s' to the project name in 'queueName'.

resp = {u'kind': u'taskqueues#task', u'queueName': u'projects/s~project_name/taskqueues/pullqq', u'payloadBase64': u'c29tZSB0ZXN0'}

Now it worked.

rriccilopes
  • 399
  • 2
  • 10