Custom API in Version 9.0

Hi Team,

 We are upgrading from version 8.1.5 to 9.0 , we noticed that post upgrade our custom api has been missing. 

As api designer is decommissioned in version 9.0 we are aware that we need to convert our api designer code in to custom dll.

when we are migrating the code to custom dll  we are only only able to see the custom methods if we attach to existing apps like QER.CompositionApi.Portal.PortalApiProject or QBM.CompositionApi.AdminApi.AdminApiProject

but we implemented these methods under custom project in version 8.1.5 , what is procedure to create a custom API project in version 9.

Parents
  • Hi Pradeep,

    sorry for the delayed reply.

    Here you can find a short explanation on how to convert API projects to API plugins: Api-development-guide

    Generally api server examples can be found in the folder \Modules\QBM\dvd\AddOn\ApiSamples of our file set.
    And this is the example of a custom api project: 

    using System.Collections.Generic;
    using System.Threading;
    using System.Threading.Tasks;
    using QBM.CompositionApi.ApiManager;
    using QBM.CompositionApi.Definition;
    using QBM.CompositionApi.PlugIns;
    using VI.Base;
    
    // This attribute will automatically assign all methods defined by this DLL
    // to the CCC module.
    [assembly: Module("CCC")]
    
    namespace QBM.CompositionApi.Sdk01_Basics
    {
        public class CustomApiProject : IMethodSetProvider
        {
            private readonly MethodSet _project;
    
            public CustomApiProject(IResolve resolver)
            {
                _project = new MethodSet
                {
                    AppId = "customapi"
                };
    
                var svc = resolver.Resolve<IExtensibilityService>();
    
                // Configure all API providers that implement IApiProviderFor<CustomApiProject>
                var apiProvidersByAttribute = svc.FindAttributeBasedApiProviders<CustomApiProject>();
                _project.Configure(resolver, apiProvidersByAttribute);
    
                var authConfig = new Session.SessionAuthDbConfig
                {
                    AuthenticationType = Config.AuthType.AllManualModules,
                    Product = "WebDesigner",
                    SsoAuthentifiers =
                    {
                        // Add the names of any single-sign-on authentifiers here
                    },
                    ExcludedAuthentifiers =
                    {
                        // Add the names of any excluded authentifiers here
                    }
                };
    
                // To explicitly set the list allowed authentication modules,
                // set the AuthenticationType to AuthType.Default and set
                // the list of ManualAuthentifiers.
    
                _project.SessionConfig = authConfig;
            }
    
            public Task<IEnumerable<IMethodSet>> GetMethodSetsAsync(CancellationToken ct = new CancellationToken())
            {
                return Task.FromResult<IEnumerable<IMethodSet>>(new[] { _project });
            }
        }
    
        public class CustomApiPlugin : IPlugInMethodSetProvider
        {
            public IMethodSetProvider Build(IResolve resolver)
            {
                return new CustomApiProject(resolver);
            }
        }
    
        public class CustomApiHelloWorld : IApiProviderFor<CustomApiProject>
        {
            public void Build(IApiBuilder builder)
            {
                builder.AddMethod(Method.Define("helloworld")
                    .AllowUnauthenticated()
                    .HandleGet(qr => new DataObject { Message = "Hello world!" }));
            }
        }
    }

    Kind regards

    Danny

Reply Children
No Data