Don't miss out Virtual Happy Hour today (April 26).
Don't miss out Virtual Happy Hour today (April 26).
Feb 16, 2016
Feb 29, 2016
Service API
Closed, Fixed and tested
Product version: EPiServer.ServiceApi.Commerce 2.0.4
Steps to reproduce
1. Install and configure Service API on a commerce sample site.
2. Add a meta field of backing type PropertyDictionaryMultiple to any variation class (for example: WineSKUContent):
[Display(Name = "Color Collection", Order = 320)] [BackingType(typeof(PropertyDictionaryMultiple))] public virtual ItemCollection<string> ColorCollection { get; set; }
3. Start the site, go to Commerce Manager, and create an entry of the variation class above. Do not set the value for the PropertyDictionaryMultiple meta field.
4. Try to retrieve the entry via the service API using this code snippet:
using (var client = new HttpClient()) { client.BaseAddress = new Uri("<your site's url>"); client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.ToString()); var response = client.GetAsync("/episerverapi/commerce/entries/<your entry code>").Result; var content = response.Content.ReadAsStringAsync(); }
Expected: The entry returned in json format
Actual: ArgumentNullException is thrown when trying to retrieve a catalog entry with a null meta field of type PropertyDictionaryMultiple.
Full stack trace:
at System.Linq.Enumerable.Select[TSource,TResult](IEnumerable`1 source, Func`2 selector)
at EPiServer.ServiceApi.Commerce.Controllers.Catalog.Construction.MetaDataModelFactory.GetValues(MetaField metaField, Dictionary`2 metaObjects)
at EPiServer.ServiceApi.Commerce.Controllers.Catalog.Construction.EntryModelFactory.<>c_DisplayClass27.<InitializeCollections>b_15(MetaField x)
at System.Linq.Enumerable.WhereSelectEnumerableIterator`2.MoveNext()
at System.Collections.Generic.List`1..ctor(IEnumerable`1 collection)
at System.Linq.Enumerable.ToList[TSource](IEnumerable`1 source)
at EPiServer.ServiceApi.Commerce.Controllers.Catalog.Construction.EntryModelFactory.InitializeCollections(Entry model, Entry entry, String language, MetaClass metaClass, CatalogDto catalog)
at EPiServer.ServiceApi.Commerce.Controllers.Catalog.Construction.EntryModelFactory.CreateEntryModel(Entry entry, String language)
at EPiServer.ServiceApi.Commerce.Controllers.Catalog.EntryController.GetCatalogEntry(String code) at lambda_method(Closure , Object , Object[] )
at System.Web.Http.Controllers.ReflectedHttpActionDescriptor.ActionExecutor.<>c_DisplayClass10.<GetExecutor>b_9(Object instance, Object[] methodParameters)
at System.Web.Http.Controllers.ReflectedHttpActionDescriptor.ExecuteAsync(HttpControllerContext controllerContext, IDictionary`2 arguments, CancellationToken