Hi,
I'm currently experiencing and testing the OData webservice framework for Navision 2013.
I have followed this example (
http://msdn.microsoft.com/en-us/library ... 0(v=nav.71).aspx) and code builds fine and
I'm able to retrieve data. Here is my code:
NAV nav = new NAV(new Uri("http://192.168.10.162:7048/DynamicsNAV70/OData/Company('CRONUS International Ltd.')"));
nav.Credentials = CredentialCache.DefaultNetworkCredentials;
// Via LINQ get all customers
var customers = from c in nav.Customer
//where c.Location_Code == "YELLOW"
orderby(c.Name)
select c;
// Write customer list to console
foreach (var c in customers)
{
Console.WriteLine(c.Name);
}
Console.ReadLine();
Console.WriteLine("Printing list of current customers:");
PrintCustomersCalledCust(nav);
Console.WriteLine("Adding new customer.");
Customer newCustomer = new Customer();
newCustomer.Name = "Customer Name";
nav.AddToCustomer(newCustomer);
nav.SaveChanges(); // <== Exception thrown here !!!!
Console.WriteLine("Printing list of current customers:");
PrintCustomersCalledCust(nav);
newCustomer.Name += "Changed";
nav.UpdateObject(newCustomer);
nav.SaveChanges();
Console.WriteLine("Printing list of current customers:");
PrintCustomersCalledCust(nav);
However it seems that the example found at MSDN above has not taken into account that you need an IDataServiceUpdateProvider if you want to post inserts/updates
back to Navision.
I'm getting this error (inner exception):
The data source must implement IDataServiceUpdateProvider to support updates.
Is it really necessary to write a provider in order to update data ? :?
I have found some code examples to implement IDataServiceUpdateProvider (
http://blogs.msdn.com/b/alexj/archive/2 ... pdate.aspx),
but I find it difficult to put together all the pieces on the specific pages.
Does someone have a working complete code based on Alex' article ?
Cheers...
Morten
Comments
If your version is 7.0 then OData is not writable. Only from version 7.1... - (NAV 2013 R2).
Try SOAP or upgrade your system to new version.
Regards,
P.
Is there any sample code where I can see how a SOAP webservice (that updates NAV) I can get some inspiration from ?