Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Small and medium business | Business Central, N...
Suggested answer

Trying to create a SO from C# using OData Service

(0) ShareShare
ReportReport
Posted on by 20

i am trying to create SO in business central using OData.

here is my code

NAV con = BCConnection.connect();
            SalesOrderHeader aa = new SalesOrderHeader
            {
                Number="123",
                CustomerNumber = "C1002",
                BillToCustomerNumber = "C1002"
        };
            con.AddObject("salesOrderHeaders", aa);
            con.SaveChanges();

with this code its giving error 

Name Value Type
InnerException "{\"error\":{\"code\":\"Application_DialogException\",\"message\":\"You may not enter numbers manually. If you want to enter numbers manually, please activate Manual Nos. in No. Series S-ORD. CorrelationId: 1756ebb5-dee8-42a5-a033-9a41cc263130.\"}}" System.Exception {Microsoft.OData.Client.DataServiceClientException}

but if i try without Number 

its saying Number cannot be null

  • noozan Profile Picture
    20 on at
    RE: Trying to create a SO from C# using OData Service

    thank you for the reply and its working fine when I enable manual number.
    still if I submit without number, its giving the following error

    InnerException "{\"error\":{\"code\":\"BadRequest\",\"message\":\"A null value was found for the property named 'number', which has the expected type 'Edm.String[Nullable=False]'. The expected type 'Edm.String[Nullable=False]' does not allow null values. CorrelationId: e12b7021-4750-4fec-bc0d-ea9056f9cd74.\"}}" System.Exception {Microsoft.OData.Client.DataServiceClientException}

    is there any way i can save without the number, as i want it to generate automatically.

  • Suggested answer
    Andrey Baludin Profile Picture
    3,941 on at
    RE: Trying to create a SO from C# using OData Service

    Hi! This is BC "No Series" error, not C#.

    Open Business Central, then open No. Series page, select number series which you use for Sales Orders (by default it's S-ORD) and set a mark on "Manual Nos." field to let you create number manually.

    If you want to generate Sales orders numbers automatically just remove Number="123" parameter from your request.

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

Daivat Vartak – Community Spotlight

We are honored to recognize Daivat Vartak as our March 2025 Community…

Announcing Our 2025 Season 1 Super Users!

A new season of Super Users has arrived, and we are so grateful for the daily…

Kudos to the February Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 292,978 Super User 2025 Season 1

#2
Martin Dráb Profile Picture

Martin Dráb 231,821 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156 Moderator

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans