vitek Posted June 14, 2018 Report Share Posted June 14, 2018 Hi there! I'm trying to add the note with API, but can't quite nail it - I'm basically taking code from the documentation and just replacing queries with my own .... , any ideas what I am doing wrong, please? Any advice appreciated! Cheers! Here is the code: category = session.query( 'NoteCategory where name is "External Note"' ).first() note = session.create('Note', { 'content': 'New note with external category', 'author': session.query('User where username is "vit.sedlacek@dazzlepictures.net"').one(), 'category': session.query('NoteCategory where name is "Internal"').one() }) task['notes'].append(note) session.commit() And the error # Result: ERROR 18:16:46.713:ftrack_api.session.Session(7088): Server reported error: ValueError(Cannot set relationship to string value.) Traceback (most recent call last): File "<string>", line 12, in <module> File "C:/Python27/Lib/site-packages\ftrack_api\session.py", line 1238, in commit result = self._call(batch) File "C:/Python27/Lib/site-packages\ftrack_api\session.py", line 1616, in _call raise ftrack_api.exception.ServerError(error_message) ftrack_api.exception.ServerError: Server reported error: ValueError(Cannot set relationship to string value.) based on code from API documentation here (http://ftrack-python-api.rtd.ftrack.com/en/stable/example/note.html?highlight=create_note): category = session.query( 'NoteCategory where name is "External Note"' ).first() note = session.create('Note', { 'content': 'New note with external category', 'author': user, 'category': category }) task['notes'].append(note) Link to comment Share on other sites More sharing options...
Remus Avram Posted June 16, 2018 Report Share Posted June 16, 2018 Hi @vitek which version of ftack-api and ftarck server are you running? The example below works for us: import ftrack_api session = ftrack_api.Session() task = session.query("Task where name is cacatcacat").one() note_category = session.query("NoteCategory where name is 'Internal'").one() content = "this is just a test" user = session.query("User where username is '<username>'").one() note = session.create("Note", { 'category': note_category, 'content': content, 'author': user }) task['notes'].append(note) session.commit() Can you assert all the returns? Link to comment Share on other sites More sharing options...
vitek Posted June 20, 2018 Author Report Share Posted June 20, 2018 Works now! Thanks Remus! Cheers Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.