recently I've been working on the custom monthly tasks report via Python API (1.7.0). And it fails everytime when tasks are created by managers with special characters in a task name, otherwise it works fine on its own. I don't want to manually rename the task in the web UI everytime it happens. I wanted to fix it in my script with exception handling block for UnicodeEncodeError. But for some reason I can't even query the task from the session to replace the wrong character in my script. I get this error:
>>> session.query('Task where parent.name is "Test Subjects" and type is "R&D"').one()
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "P:\.sys\python\Python27\lib\site-packages\ftrack_api\query.py", line 164, in one
results, metadata = self._session._query(expression)
File "P:\.sys\python\Python27\lib\site-packages\ftrack_api\session.py", line 821, in _query
results = self._call(batch)
File "P:\.sys\python\Python27\lib\site-packages\ftrack_api\session.py", line 1637, in _call
ftrack_api.exception.ServerError: Server reported error: AttributeError('unicode' object has no attribute '_sa_instance_state')
I can query the task if conditions result in getting multiple tasks from the query, but when it gets to passing the name of the task for further processing, I get this:
UnicodeEncodeError: 'ascii' codec can't encode character u'\u0161' in position 28: ordinal not in range(128)
Am I doing something wrong here? I don't understand how and why it is even possible to create a task with a special character in the task name if it's using unicode as a variable type and then it cannot be queried. Is there another way how to query the task from session? Can I change encoding in the process of reading a task name?
Thanks in advance for the reply!