Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Casper Andersen 126 posts 508 karma points
    Aug 31, 2015 @ 11:13
    Casper Andersen
    0

    Creating a GetAllCategories API

    At the moment it is possible to get all the products with an API call, i tried going into the uwebshop files, and inside the StoreApiController i created inside PublicApiController i created this

    public IEnumerable<Category> GetAllCategories()
            {
                return DomainHelper.GetAllCategories().Cast<Category>();
    
            }
    

    But it gives me some problems when i try to access it.

    Type 'uWebshop.Domain.Product' with data contract name 'Product:' is not expected. Consider using a DataContractResolver or add any types not known statically to the list of known types - for example, by using the KnownTypeAttribute attribute or by adding them to the list of known types passed to DataContractSerializer.

    Any help would be great!

  • Miklos Kanyo 2 posts 72 karma points
    Aug 15, 2020 @ 22:52
    Miklos Kanyo
    0

    I just ran into this problem now and thought I'd share how I got it working.

    You need to add a reference to System.ServiceModel and put an attribute to your method, in this case like:

    [ServiceKnownType(typeof(Category[]))]

Please Sign in or register to post replies

Write your reply to:

Draft