Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics NAV (Archived)

Create Customer using Odata Web Service

Posted on by Microsoft Employee

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

*This post is locked for comments

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: Create Customer using Odata Web Service

    Yes Customer No field automatically create in All Nav 2015 Client(Web & Desktop).

    However Customer create using OData web service keep showing me the error.

  • Suggested answer
    Suresh Kulla Profile Picture
    Suresh Kulla 43,745 on at
    RE: Create Customer using Odata Web Service

    When you create a new customer manually does it auto assign customer number ?

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: Create Customer using Odata Web Service

    Thank you Suresh.

    I attached my No. Series Setting at the end of the question.

    Default No. checked.

    Before I wrote the question, the Default No. Checked was true.

    However it keep give me the error message.

    Does any setting I should check more?

    Regards,

    Donam

  • Suggested answer
    Suresh Kulla Profile Picture
    Suresh Kulla 43,745 on at
    RE: Create Customer using Odata Web Service

    Please check in your main No. Series setup if Default No.s (field) is set to true or not, that should be true to create no. automatically.

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Tips for Writing Effective Suggested Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,280 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,235 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans