Quantcast
Channel: Microsoft Dynamics NAV Forum - Recent Threads
Viewing all articles
Browse latest Browse all 19332

Create Customer using Odata Web Service

$
0
0

Hello,

I am suffering from Inserting a customer using OData webservice.

I followed this tutorial - https://msdn.microsoft.com/en-us/library/hh166960%28v=nav.80%29.aspx

  Customer newCustomer = new Customer();
  newCustomer.Name = "Customer Name";
  nav.AddToCustomer(newCustomer);
  nav.SaveChanges();

When I execute above code, I got this error

System.InvalidOperationException: The serialized resource has a null value in key member 'No'. Null values are not supported in key members.
at System.Data.Services.Client.DataServiceContext.WriteContentProperty(XmlWriter writer, String namespaceName, ClientProperty property, Object propertyValue)
at System.Data.Services.Client.DataServiceContext.WriteContentProperties(XmlWriter writer, ClientType type, Object resource, EpmSourcePathSegment currentSegment, Boolean& propertiesWritten)
at System.Data.Services.Client.DataServiceContext.CreateRequestData(EntityDescriptor box, Boolean newline)
at System.Data.Services.Client.DataServiceContext.SaveResult.CreateChangeData(Int32 index, Boolean newline)
at System.Data.Services.Client.DataServiceContext.SaveResult.BeginNextChange(Boolean replaceOnUpdate)

I can understand the error message. I need to input Customer No manually.

However when I do same thing into Contact card.

It automatically create Contact Card No.

How can I create s Customer using OData web service with auto created Customer No.?

my current No. Series Lines setting for customer like this


Viewing all articles
Browse latest Browse all 19332


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>