can't add the note
1 1

3 posts in this topic

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)

 

Share this post


Link to post
Share on other sites

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?

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
1 1