I've written the following code to query the ODATA endpoint in Dynamics Nav 2016. I did this by creating an ODATA connected service. I have passed a company name in the URL:
var navision = new Navision(
new Uri("http://navision:7048/navision/OData/Company('Company1')"));
foreach (var foo in await navision.Foo.ExecuteAsync())
{
Console.WriteLine(foo.Name);
}
Is it possible to query all companies in Navision? When I omit the /Company(...)
section of the URL, I get an error:
DataServiceClientException: Cannot process the request because the default Microsoft Dynamics NAV company cannot be found. You can specify a default company in the service configuration file, or specify one for each tenant, or you can add a query string in the form of "company=[name]". You can see the available companies by accessing the default OData web service, Company. For more information, see "OData Web Services" in Help.