IDataServiceUpdateProvider needed to update via OData WS

mspacemspace Member Posts: 3
edited 2014-02-04 in NAV Three Tier
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

  • pbronekpbronek Member Posts: 1
    Hello,

    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.
  • mspacemspace Member Posts: 3
    I'm running NAV 2013, not R2 ... that explains the problem with updating data from an OData webservice.

    Is there any sample code where I can see how a SOAP webservice (that updates NAV) I can get some inspiration from ?
  • geordiegeordie Member Posts: 655
    Sorry for cross-forum posting ( :oops: ), can this thread be useful?
Sign In or Register to comment.