Community
Showing results for 
Search instead for 
Do you mean 
Reply

Failing companies endpoint for certain customer database

Highlighted
Copper Contributor
Posts: 214
Country: Netherlands

Failing companies endpoint for certain customer database

[ Edited ]

We have a customer with a failing API on companies level.

 

contacts/groups/opportunities work fine, but when doing a simple request on the companies endpoint with only a $top filter (or even without):

 

{{apiurl}}/api/companies?$top=10

 

 

we get this response:

 

{
    "message": "An error has occurred.",
    "exceptionMessage": "Object of type 'System.String' cannot be converted to type 'System.Nullable`1[System.Int32]'.",
    "exceptionType": "System.ArgumentException",
    "stackTrace": "   at System.RuntimeType.TryChangeType(Object value, Binder binder, CultureInfo culture, Boolean needsSpecialCast)\r\n   at System.RuntimeType.CheckValue(Object value, Binder binder, CultureInfo culture, BindingFlags invokeAttr)\r\n   at System.Reflection.MethodBase.CheckArguments(Object[] parameters, Binder binder, BindingFlags invokeAttr, CultureInfo culture, Signature sig)\r\n   at System.Reflection.RuntimeMethodInfo.InvokeArgumentsCheck(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)\r\n   at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)\r\n   at System.Reflection.RuntimePropertyInfo.SetValue(Object obj, Object value, BindingFlags invokeAttr, Binder binder, Object[] index, CultureInfo culture)\r\n   at System.Reflection.RuntimePropertyInfo.SetValue(Object obj, Object value, Object[] index)\r\n   at Act.SDK.Mapping.Mapper.MapFromWithoutCustomFields[TModel,TEntity,TMutableType](TEntity entity, TModel mapTo, DetailFormats format) in c:\\gitroot\\act.web.api\\Act.SDK.Mapping\\Mapper.cs:line 304\r\n   at Act.SDK.Mapping.Mapper.MapFromEntity[TModel,TEntity,TMutableType](TEntity entity, TModel mapTo) in c:\\gitroot\\act.web.api\\Act.SDK.Mapping\\Mapper.cs:line 250\r\n   at act.web.api.Services.CompaniesService.<>c__DisplayClass6_0.<Get>b__0(Company c) in c:\\gitroot\\act.web.api\\act.web.api\\Services\\CompaniesService.cs:line 165\r\n   at System.Linq.Enumerable.WhereSelectEnumerableIterator`2.MoveNext()\r\n   at Newtonsoft.Json.Serialization.JsonSerializerInternalWriter.SerializeList(JsonWriter writer, IEnumerable values, JsonArrayContract contract, JsonProperty member, JsonContainerContract collectionContract, JsonProperty containerProperty)\r\n   at Newtonsoft.Json.Serialization.JsonSerializerInternalWriter.SerializeValue(JsonWriter writer, Object value, JsonContract valueContract, JsonProperty member, JsonContainerContract containerContract, JsonProperty containerProperty)\r\n   at Newtonsoft.Json.Serialization.JsonSerializerInternalWriter.Serialize(JsonWriter jsonWriter, Object value, Type objectType)\r\n   at Newtonsoft.Json.JsonSerializer.SerializeInternal(JsonWriter jsonWriter, Object value, Type objectType)\r\n   at System.Net.Http.Formatting.BaseJsonMediaTypeFormatter.WriteToStream(Type type, Object value, Stream writeStream, Encoding effectiveEncoding)\r\n   at System.Net.Http.Formatting.JsonMediaTypeFormatter.WriteToStream(Type type, Object value, Stream writeStream, Encoding effectiveEncoding)\r\n   at System.Net.Http.Formatting.BaseJsonMediaTypeFormatter.WriteToStream(Type type, Object value, Stream writeStream, HttpContent content)\r\n   at System.Net.Http.Formatting.BaseJsonMediaTypeFormatter.WriteToStreamAsync(Type type, Object value, Stream writeStream, HttpContent content, TransportContext transportContext, CancellationToken cancellationToken)\r\n--- End of stack trace from previous location where exception was thrown ---\r\n   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)\r\n   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n   at System.Net.Http.HttpContent.<LoadIntoBufferAsyncCore>d__49.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)\r\n   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n   at Microsoft.AspNet.WebApi.Extensions.Compression.Server.BaseServerCompressionHandler.<HandleCompression>d__23.MoveNext() in C:\\Repository\\git\\Microsoft.AspNet.WebApi.MessageHandlers.Compression\\src\\Server\\BaseServerCompressionHandler.cs:line 257\r\n--- End of stack trace from previous location where exception was thrown ---\r\n   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)\r\n   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n   at Microsoft.AspNet.WebApi.Extensions.Compression.Server.BaseServerCompressionHandler.<SendAsync>d__21.MoveNext() in C:\\Repository\\git\\Microsoft.AspNet.WebApi.MessageHandlers.Compression\\src\\Server\\BaseServerCompressionHandler.cs:line 220\r\n--- End of stack trace from previous location where exception was thrown ---\r\n   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)\r\n   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n   at System.Web.Http.HttpServer.<SendAsync>d__24.MoveNext()"
}

Greetings,

ACT Certified Consultants
TendenZ
the Netherlands
Highlighted
Copper Contributor
Posts: 214
Country: Netherlands

Re: Failing companies endpoint for certain customer database

Update - still not fixed.

 

We created an empty copy of the database, did a Check and repair  and a rebuild database from ActDiag. Actdiag doesn't give errors anymore, however the API still fails on the companies endpoint.

 

There are now 2 companies in this database, both only with the 'name' property filled: test1 and test2.

 

Only getting the default company (/api/companies?$filter=contains(name, 'test1)) works, getting the second created company (created by me) 'test2' results in the error below.

Also not giving a fliter (/api/companies?$top=10) results in the error, now the second company ('test2') exists.

So it seems to go wrong in serializing the company to json (you can also see that because the problem originates in Newtonsoft.Json.JsonSerializer.SerializeInternal)

 

 

Greetings,

ACT Certified Consultants
TendenZ
the Netherlands
Highlighted
Platinum Elite Contributor
Posts: 14,825
Country: Australia

Re: Failing companies endpoint for certain customer database

Can you try to see if it works on a new database or the demo?
If it doesn't could be a faulty dll