How do you create "attachment" through python api

I am trying to create local linked files on Shotgun using python api. The example on the forum is given for a "sg_uploaded_movie" and sg.update/create on entity Version. I am trying to sg.create/update on the entitiy "attachment" and then link an asset item to it. But so far I am failing to create the attachment. Perhaps my "data" definition is wrong. Can you help me?

Following is my code snippet:

data = {'filename': {'local_path': '/Volumes/DCP-Playmation/Pipeline/mnt/projects/test_project/DLG_CLUESRCH_JRVS_01.wav','name': 'foo'},
'project': {'type':'Project','id':projectId}
# 'attachment_links':{'type':'Asset','id':1756}
result = sg.create('Attachment', data)


and here is the error I get:

Traceback (most recent call last):
File "test_project_script_1.py", line 105, in <module>
result = sg.create('Attachment', data)
File "/Volumes/DCP-Playmation/Pipeline/mnt/software/python-api/shotgun_api3/shotgun.py", line 614, in create
record = self._call_rpc("create", params, first=True)
File "/Volumes/DCP-Playmation/Pipeline/mnt/software/python-api/shotgun_api3/shotgun.py", line 1477, in _call_rpc
File "/Volumes/DCP-Playmation/Pipeline/mnt/software/python-api/shotgun_api3/shotgun.py", line 1684, in _response_errors
"Unknown Error"))
shotgun_api3.shotgun.Fault: API create() Attachment.filename is read only:



Is there a good way to know how to setup the data so that create/update will be successful.


  • 0
    Zaman- Asad M. -ND

    Nevermind. I have found the example on "attachment" through API.

  • 0

    For future reference, there's documentation on this and other related Shotgun API topics on the Shotgun Python API Wiki on Github

Please sign in to leave a comment.