Upload Image Python to non project entity

How do you upload an image to a NonProjectEntity? I tried the following and neither worked…

https://studiodashboard.shotgunstudio.com/page

args = {
    'code': '{}'.format(getRandomName()),
    'sg_type': types[random.randint(0, len(types)-1)],
    'tag_list': [getRandomTag(), getRandomTag()],
    'image': 'C:/Users/jmartini/Desktop/Trash/hunterVideos/thumbnails/id0960540.jpg'
}
result = sg.create('CustomNonProjectEntity08', args)

sg.update('CustomNonProjectEntity08', result['id'], {'image': {"url": image}})
sg.update('CustomNonProjectEntity08', result['id'], {'image': image})

Hi @JokerMartini,

Thanks for posting your question here. Could you please check the doc below and see it gives your some inspiration.

Let us know if further assistance needed.

Cheers,
Ben

1 Like

Thats what I was using as reference whwn writing the tool and it was giving me all kinds of errors and fails to run as mentioned above

Hey @JokerMartini,

I tried with a simplified version of your code;

>>> args = {
...     'code': 'test1',
...     'image': '/Users/masond/Desktop/1.png'
... }
>>> result = sg.create('CustomNonProjectEntity01', args) 

And was successful, only thing I can think, maybe uploading from the trash may not work?

What errors are you seeing?

-David

2 Likes

Seemed to be a security issue regarding firewall

3 Likes