Jump to content

Should I use new API and sources to learn from ?


Paidi28

Recommended Posts

Hey I previously used the old API and was wondering should I move to the new one ? Is there anything that I currently can not do in it that I can do in the old one ? Is there any other resources or tutorials for using the API other than the documentation and the "Developing with ftrack" section of the docs ?

Link to comment
Share on other sites

You can use both APIs together, so if there is something you cannot do with the new API, you can just fall back on the old API.

I don't know where to find extra tutorials, but ftrack has a public bitbucket account with some examples you can study. Most of them seem to be using the old API though.

Link to comment
Share on other sites

Hey, Björn,

Not sure whether I should post a new post so will reply here first. I have created a script using the old API for populating ftrack from some outside data. I managed to get it working but it is quite slow so would like to use the new API.  When I try something like this however I get an error TypeError: list indices must be integers, not str

task['custom_attributes']['Category'] = item_dict['sub_type']

In the docs you have

task['custom_attributes']['my_text_field'] = 'foo'

Any idea where I am going wrong ?

Link to comment
Share on other sites

It is a text value on a Task object ?

Edit* have since made some progress. My problem now appears to be that I cannot set the custom attribute or print their keys ? Thanks for the help!

[]
Traceback (most recent call last):
  File "C:\ftrack\NewAPIHandler.py", line 80, in <module>
    handler.create_new_asset(sg_dict)
  File "C:\ftrack\NewAPIHandler.py", line 46, in create_new_asset
    asset['custom_attributes']['Category'] = shotgun_item_dict['sg_sub_type']
  File "C:\Python27\lib\site-packages\ftrack_api\collection.py", line 420, in __
setitem__
    custom_attribute_value = self._get_entity_by_key(key)
  File "C:\Python27\lib\site-packages\ftrack_api\collection.py", line 386, in _g
et_entity_by_key
    configuration_id = self.get_configuration_id_from_key(key)
  File "C:\Python27\lib\site-packages\ftrack_api\collection.py", line 403, in ge
t_configuration_id_from_key
    raise KeyError(key)
KeyError: 'Category'

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...