web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Small and medium business | Business Central, N...
Answered

NAV 2017, OData, C#

(1) ShareShare
ReportReport
Posted on by 8
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?
 
I have the same question (0)
  • Verified answer
    YUN ZHU Profile Picture
    95,432 Super User 2025 Season 2 on at
    Hi, sorry, this may not be a good example, you can generate some sample code through Postman.
     
    Hope this can give you some hints.
    Thanks.
    ZHU
  • Newbie_13 Profile Picture
    8 on at
    Hi Yun!
    I didn't kow this Postman feature.
    Many thanks for your help, you've saved my week^^.

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > Small and medium business | Business Central, NAV, RMS

#1
OussamaSabbouh Profile Picture

OussamaSabbouh 2,990

#2
Jainam M. Kothari Profile Picture

Jainam M. Kothari 1,576 Super User 2025 Season 2

#3
YUN ZHU Profile Picture

YUN ZHU 1,028 Super User 2025 Season 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans