Hello All,
I'm so new to NAV, but got skills in .net development.
I've tried with succes to create new customers using a Page WebService (object ID 21), usng the following code:
ODataService.Customer c = ODataService.Customer.CreateCustomer("Gianmaria");
c.Name = "AAA New Company";
c.Address = "A Road Name, House Number 5";
c.City = "Rome";
c.Contact = "Mark Jacobs";
c.Country_Region_Code = "IT";
c.E_Mail = "mark@nowhere.it";
c.No = "101";
ODataService.NAV nav = new ODataService.NAV(new Uri("http://win-o490:7048/DynamicsNAV71/OData/"));
nav.AddToCustomer(c);
ICredentials credentials = new NetworkCredential("username", "password");
nav.Credentials = credentials;
System.Data.Services.Client.DataServiceResponse res = nav.SaveChanges();
Everything works fine, even if I'm not sure this is the right way to do. Anyway.. my problem is on Orders. I've tried to apply same logic on Order creation. I exposed NAV data by web service, again as Page and using object id 48. In code i wrote:
ODataService.SalesOrder order = ODataService.SalesOrder.CreateSalesOrder("Order", "1500", 1);
order.Sell_to_Customer_No = "101";
nav.AddToSalesOrder(order);
try
{
System.Data.Services.Client.DataServiceResponse res = nav.SaveChanges();
}
catch (DataServiceRequestException ex)
{
Exception innerEx = ex.InnerException;
System.Diagnostics.Trace.WriteLine(ex.Message + "\n" + innerEx.Message);
}
When I execute code i receive the followin message:
<?xml version="1.0" encoding="utf-8"?><m:error xmlns:m="schemas.microsoft.com/.../metadata"><m:code /><m:message xml:lang="it-IT">An error occurred while processing this request.</m:message><m:innererror><m:message>The underlying application page is not editable.</m:message><m:type>Microsoft.Dynamics.Nav.Service.ODataServiceProvider.ODataException</m:type><m:stacktrace></m:stacktrace></m:innererror></m:error>
It seem i'm violating some rule on insert.. or I'm completely wrong this time.. someone can help? Someone done same thing using Visual Studio to attach NAV WS?
my best regards,
Gianmaria