Commerce 12.5.0: Exception when creating entry with ServiceAPI 5.1

Commerce 12.5.0: Exception when creating entry with ServiceAPI 5.1

Member since: 2016
 

Hi,

I can no longer create entries by calling the service API. We upgraded from 11.8 to 12.2 before summer, and yesterday I updated to 12.5 but it didn't help.

Updating an existing entry works just fine.

This is the error I get:
Result: "{\"Message\":\"An error has occurred.\",\"ExceptionMessage\":\"There is no contentType registered for: EPiServer.Commerce.Catalog.ContentTypes.EntryContentBase\",\"ExceptionType\":\"System.NotSupportedException\",\"StackTrace\":\"   at EPiServer.Core.Internal.DefaultContentRepository.GetDefault[T](ContentReference parentLink, CultureInfo language)\\r\\n   at EPiServer.Core.Internal.DefaultContentRepository.GetDefault[T](ContentReference parentLink)\\r\\n   at EPiServer.ServiceApi.Commerce.Controllers.Catalog.Persistence.EntryModelCommitter.SaveCatalogEntry(Entry catalogEntry)\\r\\n   at EPiServer.ServiceApi.Commerce.Controllers.Catalog.EntryController.PostCatalogEntry(Entry catalogEntry)\\r\\n   at lambda_method(Closure , Object , Object[] )\\r\\n   at System.Web.Http.Controllers.ReflectedHttpActionDescriptor.ActionExecutor.<>c__DisplayClass10.<GetExecutor>b__9(Object instance, Object[] methodParameters)\\r\\n ... 

And this is the model I'm using:

var model = new Entry
{
Code = "111111",
Catalog = "Books",
EndDate = DateTime.UtcNow.AddDays(100),
EntryType = "Variant",
InventoryStatus = "Enabled",
IsActive = false,
MetaClass = "BookVariant",
Name = "Test 111111",
StartDate = DateTime.UtcNow
};

Thanks,
Rickard

#195841 Aug 09, 2018 8:33
  • Member since: 2011
     

    do you have BookVariant metaclass created? It sounds to me there has been a problem with it

    #195842 Aug 09, 2018 10:20
  • Member since: 2016
     

    Screenshot of Commerce manager

    Is this what you mean? Can I try to recreate it or create a new for testing?

    /Rickard

    #195850 Aug 09, 2018 12:33
  • Member since: 2015
     

    Can you try setting EntryType = "Variation"?

    #195851 Aug 09, 2018 12:37
  • Member since: 2016
     

    I tried this and got the same error.

    var model = new Entry
    {
    Code = "111111",
    Catalog = "Books",
    EndDate = DateTime.UtcNow.AddDays(100),
    EntryType = "Variation",
    InventoryStatus = "Enabled",
    IsActive = false,
    MetaClass = "BookVariant",
    Name = "Test 111111",
    StartDate = DateTime.UtcNow
    };

    #195852 Aug 09, 2018 12:40
  • Member since: 2015
     

    Then I agree with Quan that smthing wrong with meta class BookVariant. Can you create a similar one for testing?

    #195887 Aug 10, 2018 5:00
  • Member since: 2011
     

    I would suggest to try these steps:

    • First restart your website to make sure the content types and metaclasses are properly mapped, and try again
    • If it still does not work, can you try to add a strongly typed content type for BookVariant?
    #195891 Aug 10, 2018 9:16
  • Member since: 2016
     

    Hi,

    I have restarted the website, still getting error.

    I created a new metaclass and got the same error.
    I tried with another metaclass that we created in the beginning of the project. Same error.

    We have this class for BookVariant. It has worked earlier:

    [CatalogContentType(
    GUID = "D7C2DC51-74C7-4CB8-A6F4-79CA9A0DD980",
    MetaClassName = "BookVariant",
    DisplayName = "Book Variant",
    Description = "Display book variant")]
    public class BookVariant : ByggtjanstVariantBase
    {
    //properties
    }

    public class ByggtjanstVariantBase : VariationContent
    {
    }

    The one thing that might have changed is BookVariant inheriting from ByggtjanstVariantBase instead of VariationContent. Could that cause problems?

    Thanks,
    Rickard

    #195945 Aug 13, 2018 12:56
  • Member since: 2015
     

    That's strange. I'll try to reproduce at my side...

    #195946 Aug 13, 2018 13:01
  •  

    Hi,

    ByggtjanstVariantBase should not be the problem here.

    Could you check if the contentTypeModel in the following snippet code is not null?

    var metaClassId = MetaClass.Load(CatalogContext.MetaDataContext, "BookVariant");
    
    var contentTypeModel = ServiceLocator.Current.GetInstance<MetaClassToContentTypeMap>().GetContentTypeModel(metaClassId);

    #196061 Aug 17, 2018 12:12
  • Member since: 2016
     

    Thanks,

    contentTypeModel is not null when I run your code snippet.

    #196064 Aug 17, 2018 12:32
First   1 2   Last