Jump to content

PermissionError when trying to commit task status change


Alican

Recommended Posts

Posted

Hello, I am trying to make a python module to change task status for a given task ID

I have set my user role settings to have everything enabled as shown in the image. 

What am I doing wrong?

############################

import ftrack_api

session = ftrack_api.Session()

assigned_tasks = session.query('select link from Task where assignments any (resource.username = "{0}")'.format(session.api_user))
'''
for task in assigned_tasks:
    print u' / '.join(item['name'] for item in task['link']), task['id'], task['status']['name']
'''
task_id = "9b8f0400-3324-11e6-8686-02420a280107"

def updateTask(task_id,status_name):
    task = session.query('Task where id is '+task_id+'').one()
    task['status']['name'] = status_name
    session.commit()
    
updateTask(task_id,'In Progress')

 

# Result: L:\HAL\LIVEAPPS\apps\Scripts\NUKE/python/ftrack\requests\packages\urllib3\util\ssl_.py:90: InsecurePlatformWarning: A true SSLContext object is not available. This prevents urllib3 from configuring SSL appropriately and may cause certain SSL connections to fail. For more information, see https://urllib3.readthedocs.org/en/latest/security.html#insecureplatformwarning.

InsecurePlatformWarning

ERROR 18:13:29.598:ftrack_api.session.Session(7268): Server reported error: PermissionError(Permission denied: not allowed to 'update' 'TaskStatus'. Missing the required 'Can access settings' permission.)

Traceback (most recent call last):

File "<string>", line 19, in <module>

File "<string>", line 16, in updateTask

File "L:\HAL\LIVEAPPS\apps\Scripts\NUKE/python\ftrack_api\session.py", line 1165, in commit

result = self._call(batch)

File "L:\HAL\LIVEAPPS\apps\Scripts\NUKE/python\ftrack_api\session.py", line 1544, in _call

raise ftrack_api.exception.ServerError(error_message)

ftrack_api.exception.ServerError: Server reported error: PermissionError(Permission denied: not allowed to 'update' 'TaskStatus'. Missing the required 'Can access settings' permission.)

L:\HAL\LIVEAPPS\apps\Scripts\NUKE/python/ftrack\requests\packages\urllib3\util\ssl_.py:90: InsecurePlatformWarning: A true SSLContext object is not available. This prevents urllib3 from configuring SSL appropriately and may cause certain SSL connections to fail. For more information, see https://urllib3.readthedocs.org/en/latest/security.html#insecureplatformwarning.

InsecurePlatformWarning

 

 

 

 

 

I have read the API documentation and searched your forums as well... and came across this, but I couldn't make it work for my code. 

 

Thanks!

 

Ali

ftrack_role_settings.jpg

Posted

Hi Ali,

def updateTask(task_id,status_name):
    task = session.query('Task where id is '+task_id+'').one()
    task['status']['name'] = status_name
    session.commit()
    
updateTask(task_id,'In Progress')

The code above is changing the name of the status that the task has, rather than changing the status of the task.

What you would like to do is something like (haven't test run the code):

def updateTask(task_id,status_name):
    status = sesssion.query('Status where name is "{0}"'.format(status_name)).one()
    task = session.query('Task where id is '+task_id+'').one()
    task['status'] = status
    session.commit()
    
updateTask(task_id,'In Progress')

I hope this helps

Posted

Oh that's great! I'm glad it didn't give me permission......... I understand my mistake here, and the code now works.

Thank you so much for the prompt reply Mattias!

Ali

Archived

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

×
×
  • Create New...