Scifabric / pybossa

PYBOSSA is the ultimate crowdsourcing framework (aka microtasking) to analyze or enrich data that can't be processed by machines alone.

Home Page:http://pybossa.com

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

[HTTP 403] You must request a task first

reezi opened this issue · comments

commented

Hello, 🙂

I am using external uids and trying to submit taskruns in python, following instructions of these pages:
https://docs.pybossa.com/api/taskrun/intro/#creating-a-taskrun
https://docs.pybossa.com/api/task/external/

I requested a task using /api/project/<project_id>/newtask first.
Then I POST /api/taskrun with:

headers = {'Authorization': 'Bearer <toke retrieved from /api/auth/project/<short_name>/token>'}
params = {'external_uid': 1}
body = {'project_id': 8, 'task_id': 1952, 'info': {'bla': 'bla'}}

However, I get a response as follows: 😕

{
      "action": "POST", 
      "exception_cls": "Forbidden", 
      "exception_msg": "You must request a task first!", 
      "status": "failed", 
      "status_code": 403, 
      "target": "taskrun"
}

The guard in pybossa which seems to refuse me is the _ensure_task_was_requested method in https://github.com/Scifabric/pybossa/blob/master/pybossa/contributions_guard.py.

What am I missing? 🤔

Yes, this is expected. You get the task, but you have to sign it. You can do it like this:

http://server/project/short_name/task/ID

When you visit that URL, the task is signed and then you will be able to save the taskrun for it.