Hi Community,
My goal is to create a C# Console App with Visual Studio 2019 for calling NAV 2017 OData API.
I have generated the proxy with OData Connected Service.
I have a first snippet which works fine :
var context = new NAV(new Uri(serviceRoot));
context.Credentials = new NetworkCredential(/mylogin/, /mypassword/);
var nbCarriers = context.Transporteurs.Count();
Console.WriteLine(/Number of Carriers:/ + nbCarriers);
I have an error with a second snippet :
var context = new NAV(new Uri(serviceRoot));
context.Credentials = new NetworkCredential(/mylogin/, /mypassword/);
var myCarriers = context.Transporteurs.Execute();
foreach (var myCarrier in myCarriers) { Console.WriteLine(/{0} {1}/, myCarrier.Name, myCarrier.Code); }
Microsoft.OData.ODataException : 'When writing a JSON response, a user model must be specified and the entity set and entity type must be passed to the ODataMessageWriter.CreateODataResourceWriter method or the ODataResourceSerializationInfo must be set on the ODataResource or ODataResourceSet that is being written.'
I have tried to find somme resources about this problem via Google but I can't find a good solution.
Can you hlep me, please?