SData-2.0 icon indicating copy to clipboard operation
SData-2.0 copied to clipboard

SalesQuotations in JSON - An item with the same key has already been added.

Open geoffo opened this issue 10 years ago • 3 comments

I am attempting to retrieve a SalesQuotations feed in JSON from Sage 50 Accounts but I am retrieving an error stating "An item with the same key has already been added.". If I retrieve the same feed but in atom/xml (by just removing format=json from the URL), the feed is retrieved with no errors.

Any ideas why this is occurring? It appears to be a bug with the JSON implementation due to atom/xml working fine with the same data. Below is the stack trace for reference.

stackTrace

System.ArgumentException: An item with the same key has already been added. at System.ThrowHelper.ThrowArgumentException(ExceptionResource resource) at System.Collections.Generic.Dictionary2.Insert(TKey key, TValue value, Boolean add) at System.Collections.ObjectModel.KeyedCollection2.AddKey(TKey key, TItem item) at System.Collections.ObjectModel.KeyedCollection2.InsertItem(Int32 index, TItem item) at System.Collections.ObjectModel.Collection1.Add(T item) at Sage.Common.Syndication.Json.Utilities.CollectionUtils.AddRange[T](IList1 initial, IEnumerable1 collection) at Sage.Common.Syndication.Json.Serialization.DefaultContractResolver.CreateObjectContract(Type objectType) at Sage.Common.Syndication.JsonSerializer.Resolver.CreateObjectContract(Type objectType) at Sage.Common.Syndication.Json.Serialization.DefaultContractResolver.CreateContract(Type objectType) at Sage.Common.Syndication.Json.Serialization.DefaultContractResolver.ResolveContract(Type type) at Sage.Common.Syndication.Json.Serialization.JsonSerializerInternalWriter.GetContractSafe(Object value) at Sage.Common.Syndication.Json.Serialization.JsonSerializerInternalWriter.SerializeList(JsonWriter writer, IList values, JsonArrayContract contract, JsonProperty member, JsonContract collectionValueContract) at Sage.Common.Syndication.Json.Serialization.JsonSerializerInternalWriter.SerializeValue(JsonWriter writer, Object value, JsonContract valueContract, JsonProperty member, JsonContract collectionValueContract) at Sage.Common.Syndication.Json.Serialization.JsonSerializerInternalWriter.WriteMemberInfoProperty(JsonWriter writer, Object memberValue, JsonProperty property, JsonContract contract) at Sage.Common.Syndication.Json.Serialization.JsonSerializerInternalWriter.SerializeObject(JsonWriter writer, Object value, JsonObjectContract contract, JsonProperty member, JsonContract collectionValueContract) at Sage.Common.Syndication.Json.Serialization.JsonSerializerInternalWriter.SerializeValue(JsonWriter writer, Object value, JsonContract valueContract, JsonProperty member, JsonContract collectionValueContract) at Sage.Common.Syndication.Json.Serialization.JsonSerializerInternalWriter.Serialize(JsonWriter jsonWriter, Object value) at Sage.Common.Syndication.Json.JsonSerializer.SerializeInternal(JsonWriter jsonWriter, Object value) at Sage.Common.Syndication.Json.JsonSerializer.Serialize(JsonWriter jsonWriter, Object value) at Sage.Common.Syndication.JsonSerializer.SaveToStream(Object obj, Stream stream, TextEncoding encoding, ObjectType type, InclusionNode inclusionTree) at Sage.Common.Syndication.JsonSerializer.SaveToStream(IFeed feed, Stream stream, ISerializationSettings settings, InclusionNode inclusionTree) at Sage.Integration.Messaging.Request.ProcessResponse(IResponse response, IRequest request) at Sage.Integration.Messaging.Request.OnPostProcessRequest() at Sage.Integration.Messaging.Request.Process(RequestTargetInvoker invoker) at Sage.Integration.Adapter.AdapterController.RealAdapterController.Process(IRequest request) at Sage.Integration.Adapter.AdapterController.RealAdapterController.ProcessWorker(IProtocolRequest protocolRequest) at Sage.Integration.Adapter.AdapterController.Process(IProtocolRequest request) at Sage.Integration.Messaging.MessagingService.Process(IProtocolRequest protocolRequest)

geoffo avatar Mar 27 '15 17:03 geoffo

I've replicated the issue and can confirm it's a bug with the Sage 50 Accounts Sdata implementation so I've raised it with the Accounts team.

darroncockram avatar Mar 28 '15 08:03 darroncockram

Hi, this is still an issue. Is this something that will get added to the roadmap for fixes? Or will we need to wait for oData?

asterix187 avatar Feb 14 '16 11:02 asterix187

It's definitely on the Accounts backlog but there's no ETA as to when it might be picked up to be worked on yet I'm afraid.In the meantime the workaround would be to use atom/xml format.

darroncockram avatar Feb 14 '16 14:02 darroncockram