Vague error when uploading media through the python shotgun API

I am getting a very vague error when trying to upload media to shotgun using the python API. I first got an SSL error but, after looking through some of the forums, I found that one solution to this problem was to manually update the ca_certs field when initializing the shotgun object. I did this, and pointed the object to the “shotgun_api3/lib/httplib2/python3/cacerts.txt” file. After doing that, I got a new error, which i will paste below, along with the code which prompted that error. If anyone has any insight into this error, or has experienced the same problem, I would really appreciate the help. Thank you for your time. Also, I starred out some info, but that shouldn’t change the meaning of any code.

The code is:

sg = shotgun_api3.Shotgun(serverPath, scriptName, scriptKey, ca_certs=“*******/includes/pythonTools/pycharmProjects/shotgunProject/newEnvironment/lib/python2.7/shotgun_api3/lib/httplib2/python3/cacerts.txt”)
fileName = “/********/”
result2 = sg.upload(“Shot”, 7113, fileName, display_name=“test_shot”)
data = { ‘project’: {‘type’: ‘Project’, ‘id’: 466},
‘code’: ‘test_shot_010’,
‘description’: ‘test uploading a shot’,
‘sg_path_to_frames’: fileName,
‘sg_status_list’: ‘rev’}
result = sg.create(‘Version’, data)

and the error is:

Traceback (most recent call last):
File "//sandbox/includes/pythonTools/pycharmProjects/shotgunProject/", line 16, in
result2 = sg.upload(“Shot”, 7113, fileName, display_name=“test_shot”)
File "/
/Library/Python/3.9/lib/python/site-packages/shotgun_api3/", line 2431, in upload
return self._upload_to_storage(entity_type, entity_id, path, field_name, display_name,
File "/
/Library/Python/3.9/lib/python/site-packages/shotgun_api3/", line 2499, in _upload_to_storage
raise ShotgunError("Could not upload file successfully, but "
shotgun_api3.shotgun.ShotgunError: Could not upload file successfully, but not sure why.
Path: /
Url: https://
Error: 0
Value is not legal.

1 Like

We experience this too, it is very intermittent.
It seems like a general error about getting an unexpected empty response from the server.
Normally .create should return a dictionary of the created entity.

That’s as much insight as I can offer. Perhaps the server crashes before returning the result? The entity does get created, I think.

I wonder if it shows up in the Shotgun guys’ metrics.

Thanks for the response! As far as I can tell, the video file which I’m trying to upload is not getting created/stored anywhere in the show I am uploading it to.

You seem to be uploading media to a Shot instead of a version and creating the version afterwards.

You need to first create a version, save that dict, then upload the media to the correct field on that version using the version id from the dict