cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

CreateNewCatalogItem API and the Catalog Item image

We are running App Portal 2019R1.

We had been using a powershell script based on the one Flexera provides to import new catalog items. In this script a catalog item is created and then at a later stage the icon is added (via SQL Update)

We are now moving to C# code and are rewriting our automation.

My question is around the CreateNewCatalogItem API and the Catalog Item image.

We want all new items to have a default icon that has already been imported. Can/should we use the fields related to icon in the API

   <icon>base64Binary</icon>

   <iconExtension>string</iconExtension>

 

Or could we use the UpdateCatalotImage API.

Like I said, we do want to use the same image every time, what’s the best way to do this?

Thanks in advance.

(1) Solution

You should not use the icon fields provided as part of the CreateNewCatalogItem API.  If you do this, it will upload a copy of the icon for each catalog item into the <AppPortal>\Web\Backgrounds\Images folder on your server, and each image file will be named based on the Catalog Title provided plus the file extension you pass in the API (e.g. if you upload an image called Visio.png for a catalog item called Visio Professional 2016, the file will be uploaded to the server and renamed to "Visio Professional 2016.png").  This is why our bulk import script uses NULL for those fields (to avoid the file upload and rename) and then simply sets the image name in the database afterward.  This does require manually uploading the image files to the server (we technically could do that file copy as part of the script, but chose not to).  I wasn't aware there was a new API for UpdateCatalogImage (Flexera Engineering added many API's based on the bulk import script we provided them so there would be an API method to replace the direct SQL updates we were doing), but it looks like that API might do what you need it to.  I would still suggest passing NULL for the iconAsBase64 parameter, but it looks like the iconNameWithExtension should allow you to specify the single icon you want to use for all catalog items.  Then you'll still need to manually copy that image file to the server in the correct folder (<AppPortal>\Web\Backgrounds\Images).

Caveat: I haven't tried this API, so I'm not sure what the behavior will be when passing NULL for the iconAsBase64 parameter.  It's possible this won't work, in which case you'll probably need to continue using the SQL update code.

Anything expressed here is my own view and not necessarily that of my employer, Flexera. If my reply answers a question you have raised, please click "ACCEPT AS SOLUTION".

View solution in original post

(2) Replies

You should not use the icon fields provided as part of the CreateNewCatalogItem API.  If you do this, it will upload a copy of the icon for each catalog item into the <AppPortal>\Web\Backgrounds\Images folder on your server, and each image file will be named based on the Catalog Title provided plus the file extension you pass in the API (e.g. if you upload an image called Visio.png for a catalog item called Visio Professional 2016, the file will be uploaded to the server and renamed to "Visio Professional 2016.png").  This is why our bulk import script uses NULL for those fields (to avoid the file upload and rename) and then simply sets the image name in the database afterward.  This does require manually uploading the image files to the server (we technically could do that file copy as part of the script, but chose not to).  I wasn't aware there was a new API for UpdateCatalogImage (Flexera Engineering added many API's based on the bulk import script we provided them so there would be an API method to replace the direct SQL updates we were doing), but it looks like that API might do what you need it to.  I would still suggest passing NULL for the iconAsBase64 parameter, but it looks like the iconNameWithExtension should allow you to specify the single icon you want to use for all catalog items.  Then you'll still need to manually copy that image file to the server in the correct folder (<AppPortal>\Web\Backgrounds\Images).

Caveat: I haven't tried this API, so I'm not sure what the behavior will be when passing NULL for the iconAsBase64 parameter.  It's possible this won't work, in which case you'll probably need to continue using the SQL update code.

Anything expressed here is my own view and not necessarily that of my employer, Flexera. If my reply answers a question you have raised, please click "ACCEPT AS SOLUTION".

Passing in a Null value for iconAsBase64 worked.

I referenced an already imported Image file for the iconNameWithExtensionand parameter. It related the specified Catalog Item (packageID parameter) with the image. This is great. Thanks.