Creating a ReviewSessionObject with asset linked to no task
0

2 posts in this topic

Hello everyone!

For the needs of our production, i'm developping a tool that will have to create ReviewSessions filleds with ReviewSessionsObject on AssetsVersion that are not linked to a task. Basically, i need to use the api to do what this button in the review session would do:
button.png.1b2d071473cdd3653f996cc11153d7e6.png

 

To achieve this i have written the following code:

assetParent = session.query('Project where name is "MyProject"').first()
assetType = session.query('AssetType where name is "Upload"').one()

asset = session.create('Asset',{
    'name': 'MyAsset',
    'type': assetType,
    'parent': assetParent
})

assetVersion = session.create('AssetVersion',{
    'Asset' : asset,
})

review_session_objects  = session.create('ReviewSessionObject', {
    'name': 'Test',
    'description': 'This is a test',
    'review_session': session.query('ReviewSession where name is "MyReviewSession"').first(),
    'asset_version' : assetVersion
})

assetVersion.create_component(
    'image.png',
    data={'name': 'FileName'},
    location=session.query('Location where name is "ftrack.server"').one()
)

session.commit()

which outputs me the following error message:

Server reported error: PermissionError(Permission denied: not allowed to 'create' 'FileComponent'. Missing the required 'READ_PROJECT' permission.)
Traceback (most recent call last):
  File "C:\Python39\lib\site-packages\ftrack_api\session.py", line 1912, in create_component
    collection = clique.parse(path)
  File "C:\Python39\lib\site-packages\clique\__init__.py", line 248, in parse
    raise ValueError('Value did not match pattern.')
ValueError: Value did not match pattern.
Traceback (most recent call last):
  File "C:\Python39\lib\site-packages\ftrack_api\session.py", line 1912, in create_component
    collection = clique.parse(path)
  File "C:\Python39\lib\site-packages\clique\__init__.py", line 248, in parse
    raise ValueError('Value did not match pattern.')
ValueError: Value did not match pattern.

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:\Python39\lib\site-packages\ftrack_api\entity\location.py", line 249, in add_components
    self._register_components_in_location(
  File "C:\Python39\lib\site-packages\ftrack_api\entity\location.py", line 409, in _register_components_in_location
    self.session.commit()
  File "C:\Python39\lib\site-packages\ftrack_api\session.py", line 1265, in commit
    result = self.call(batch)
  File "C:\Python39\lib\site-packages\ftrack_api\session.py", line 1643, in call
    raise ftrack_api.exception.ServerError(error_message)
ftrack_api.exception.ServerError: Server reported error: PermissionError(Permission denied: not allowed to 'create' 'FileComponent'. Missing the required 'READ_PROJECT' permission.)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "c:\Users\florent.dupont\Documents\ReviewVR_test\FtrackTest.py", line 33, in <module>
    assetVersion.create_component(
  File "C:\Python39\lib\site-packages\ftrack_api\entity\asset_version.py", line 47, in create_component
    return self.session.create_component(path, data=data, location=location)
  File "C:\Python39\lib\site-packages\ftrack_api\session.py", line 1921, in create_component
    return self._create_component(
  File "C:\Python39\lib\site-packages\ftrack_api\session.py", line 1994, in _create_component
    location.add_component(component, origin_location, recursive=False)
  File "C:\Python39\lib\site-packages\ftrack_api\entity\location.py", line 89, in add_component
    return self.add_components(
  File "C:\Python39\lib\site-packages\ftrack_api\entity\location.py", line 254, in add_components
    raise ftrack_api.exception.LocationError(
ftrack_api.exception.LocationError: Failed to register components with location <ServerLocation("ftrack.server", 3a372bde-05bc-11e4-8908-20c9d081909b)> due to error:
b'    'Server reported error: PermissionError(Permission denied: not allowed to 'create' 'FileComponent'. Missing the required 'READ_PROJECT' permission.)
b'    'Transferred component data that may require cleanup: [(<dynamic ftrack FileComponent object 2661302031888>, 'f6212010-f527-44d2-ac3e-5f1034c8c69b')]

Now my API key has the same right as my user and the user can definitly create it from the ftrack UI.

I have tried adding the component on an AssetVersion that was created via the UI and it works, so i believe there's something wrong with the way i create my Asset, AssetVersion or my ReviewSessionObject, but i cannot figure out what, and i've found no useful information on this matter in the documentation.

Thanks in advance for any help on this :)

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
0