Create Icon entity through the api

Hi I’m in the process of migrating one project from a shotgun site to another sg site (political reasons).
And in my source sg site, we have a lot of custom status with custom icons, in order to not create them by hand, I 'm doing a little loop in python to copy the custom status with their icons from one site to the other.

sg.create(‘Icon’, {‘name’: sourceIcon[‘name’], ‘image_data’: sourceIcon[‘image_data’]})

But I got the following error:
shotgun_api3.shotgun.Fault: API create() CRUD ERROR #7: Entity of type Icon cannot be created by this user. Rule: API Admin – PermissionRule 691: DENY create_entity FOR entity_type => Icon

If it is not possible with python, can I do this with the rest api? Thanks!


hi @macbeth,

Sorry for the late response. It is permission error. API user doesn’t allow to create Icon. I tried to use human user to run the script. It works. I don’t what data you used for sourceIcon['image_data']. If it is a image path like sg.create(‘Icon’, {‘name’: ‘new_icon_name’, ‘image_data’: ‘a.jpg’}), after you run the script, shotgun site would be crashed.

The correct way to use this api is

sg.create('Icon', {'name': 'New Icon 99', 'icon_type': 'custom_status', 'display_type': 'image', 'image_data': '<hex_encoded_16px_wide_jpg>'}).

May I ask what is your use case? We will decide to disable this dangers api or update document.



1 Like

Hi! Thanks! Will use the user as you suggested, I am migrating one project to another shotgun site, so I’m taking the string hex code from another icon entity just from another site, so it should work.

I saw a post from a guy who tried the same.

1 Like

Oh my goodness, thanks for testing the API with a HumanUser @jing.liu this is definitely going to come in handy. Thanks @macbeth for tagging my previous post!