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

CreateNewCatalogItem API

We’re on App Portal 2019R1 We use automation to Add new Application Catalog Items and do in-place updates of existing Catalog items (where only the SCCM assignment ID’s and App version might change, this way we can keep all the associated icons and approval workflows).

The automation is currently PowerShell scripts, which call the API’s and are based on the PowerShell script Flexera provides to bulk import Catalog Items. We are now looking updating out automation, using C# and making it more modular.

When we try testing the CreateNewCatalogItem API using Postman, it is complaining about the type parameter. We have always had this set to a value of 15 in PowerShell as 15 means Application, but when my developer tried this value she got an error (see attached).

Has anyone else come across this or have any tips or ideas on how we can best use this API?

(1) Solution
CharlesW
By Level 12 Flexeran
Level 12 Flexeran

I've always set the type to 15 as well.. Both in powershell, and in C#.. I don't use postman that much but you would think that it would use the same value.. Not sure if it will help, but the following is some old C# code I've used for testing in the past to create a catalog item...

public static void createCatalogItemIntegration(IntegrationAPI.Integration integration)
        {

             String iconPath = "c:\\testicons\\myicon.jpg";
             byte[] icon = null;
             String iconExtension = "jpg";

             if (File.Exists(iconPath))
             {
                 icon = File.ReadAllBytes(iconPath);
             }
            try
            {
                 //createnewCatalogItem parameters
                String productName = "My catalog item created with integration.asmx";
                String companyName = "My Company Name";
                String version = "1.0";
                String searchKeywords = "";
                String shortDescription = "short description";
                String longDescription = "Long Description";
                int type = 15; //15=application, 0 = package
                bool visible = true;
                String flexeraID = "";
                int TemplatePackageID = 10;
                String csvCategoryNames = "General, Support";
                String createdBy = "support\\CharlesWeber";
                //End createnewCatalogItem parameters

                String CM12AppID = "ScopeId_6BE7A5F5-8F60-4566-8FF4-B53CECE08710/Application_49b0847d-a6cf-446e-b048-b3b290d7080d/2";
                
                int packageID = integration.CreateNewCatalogItem(productName, companyName, version, searchKeywords, shortDescription, longDescription, type, visible, icon, iconExtension, flexeraID, TemplatePackageID, csvCategoryNames, createdBy);
                Console.WriteLine(packageID);
                integration.AddCM12App(packageID, CM12AppID, DeploymentTarget.DeployToComputer, true); 
            }
            catch (Exception e)
            {
                Console.WriteLine(e.ToString());
            }

        }

 

 

View solution in original post

(2) Replies
CharlesW
By Level 12 Flexeran
Level 12 Flexeran

I've always set the type to 15 as well.. Both in powershell, and in C#.. I don't use postman that much but you would think that it would use the same value.. Not sure if it will help, but the following is some old C# code I've used for testing in the past to create a catalog item...

public static void createCatalogItemIntegration(IntegrationAPI.Integration integration)
        {

             String iconPath = "c:\\testicons\\myicon.jpg";
             byte[] icon = null;
             String iconExtension = "jpg";

             if (File.Exists(iconPath))
             {
                 icon = File.ReadAllBytes(iconPath);
             }
            try
            {
                 //createnewCatalogItem parameters
                String productName = "My catalog item created with integration.asmx";
                String companyName = "My Company Name";
                String version = "1.0";
                String searchKeywords = "";
                String shortDescription = "short description";
                String longDescription = "Long Description";
                int type = 15; //15=application, 0 = package
                bool visible = true;
                String flexeraID = "";
                int TemplatePackageID = 10;
                String csvCategoryNames = "General, Support";
                String createdBy = "support\\CharlesWeber";
                //End createnewCatalogItem parameters

                String CM12AppID = "ScopeId_6BE7A5F5-8F60-4566-8FF4-B53CECE08710/Application_49b0847d-a6cf-446e-b048-b3b290d7080d/2";
                
                int packageID = integration.CreateNewCatalogItem(productName, companyName, version, searchKeywords, shortDescription, longDescription, type, visible, icon, iconExtension, flexeraID, TemplatePackageID, csvCategoryNames, createdBy);
                Console.WriteLine(packageID);
                integration.AddCM12App(packageID, CM12AppID, DeploymentTarget.DeployToComputer, true); 
            }
            catch (Exception e)
            {
                Console.WriteLine(e.ToString());
            }

        }

 

 

Thanks Charles, my developers used that code and it helped them towards creating a catalog item. 

They mentioned that the type issue they were getting was with the HTTP protocols but using SOAP there was no issue with the type. 

Cheers,

Nicola