0

Adding Tasks to TemplateTasks via API

Hello

I tried to add a TaskTemplate with related tasks and further linked CustomEntities via the API.

data={
      "task_template": {"type": "TaskTemplate",
                        "id": 1},
      "content": "testtask"
      }
newentity=sg.create("Task", data)



I experienced a similar behaviour as stated on the following request:
https://support.shotgunsoftware.com/entries/52179-solved-task-templates-adding-a-new-task

I have to link the Tasks to a project, otherwise i get the following error:

XMLRPC Fault 103:
API create() missing 'project' attribute:
[{"value"=>"testtask", "field_name"=>"content"},
 {"value"=>{"type"=>"TaskTemplate", "id"=>1}, "field_name"=>"task_template"}]
--------------------------------------------------------------------------------
Traceback (most recent call last):
  File "/nfshome/bah/workspace/pl_syncomania/sandbox/doit.py", line 14, in <module>
    newentity=sg.create("Task", data)
  File "/nfshome/bah/workspace/pl_external_libs/shotgun_api/shotgun_api/shotgun_api3.py", line 391, in create
    resp = self._api3.create(args)
  File "/nfshome/bah/workspace/pl_external_libs/shotgun_api/shotgun_api/shotgun_api3.py", line 550, in callable
    return self.meta_caller(attr, *args, **kwargs)
  File "/nfshome/bah/workspace/pl_external_libs/shotgun_api/shotgun_api/shotgun_api3.py", line 557, in meta_caller
    (self.__class__.__name__, attr, self.__class__.__name__)
  File "<string>", line 1, in <module>
  File "/nfshome/bah/workspace/pl_external_libs/shotgun_api/shotgun_api/shotgun_api3.py", line 1849, in __call__
    return self.__send(self.__name, args)
  File "/nfshome/bah/workspace/pl_external_libs/shotgun_api/shotgun_api/shotgun_api3.py", line 2216, in __request
    verbose=self.__verbose
  File "/nfshome/bah/workspace/pl_external_libs/shotgun_api/shotgun_api/shotgun_api3.py", line 1883, in request
    return self.single_request(host, handler, request_body, verbose)
  File "/nfshome/bah/workspace/pl_external_libs/shotgun_api/shotgun_api/shotgun_api3.py", line 1916, in single_request
    return self.parse_response(response)
  File "/nfshome/bah/workspace/pl_external_libs/shotgun_api/shotgun_api/shotgun_api3.py", line 2057, in parse_response
    return self._parse_response(file, None)
  File "/nfshome/bah/workspace/pl_external_libs/shotgun_api/shotgun_api/shotgun_api3.py", line 2088, in _parse_response
    return u.close()
  File "/nfshome/bah/workspace/pl_external_libs/shotgun_api/shotgun_api/shotgun_api3.py", line 1486, in close
    raise Fault(**self._stack[0])

I think this is a bug, since I can remove the project-attribute with the following line without any problem:

task=sg.update("Task", 719, data = {"project": None})

Kind regards,
thomas

1 comment

  • 0
    Avatar
    KP

    This is indeed a bug and we've logged it for a fix. But there's a simple workaround. You can specify any valid Project when calling create() and the method will succeed. While the Task will show a Project association in the TaskTemplate, this value is meaningless. Whenever the TaskTemplate is applied to an entity, the Project field is ignored and the Task will be automatically linked to the Project that the entity is linked to.

    We'll get it fixed shortly.

Please sign in to leave a comment.