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

Announcements

No record found.

News and Announcements icon
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
    98,416 Super User 2026 Season 1 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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Stars!

Congratulations to our 2025 Community Spotlights

Thanks to all of our 2025 Community Spotlight stars!

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

#1
OussamaSabbouh Profile Picture

OussamaSabbouh 1,958 Super User 2026 Season 1

#2
YUN ZHU Profile Picture

YUN ZHU 1,101 Super User 2026 Season 1

#3
Dhiren Nagar Profile Picture

Dhiren Nagar 959 Super User 2026 Season 1

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans