web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

News and Announcements icon
Community site session details

Community site session details

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

create a Custom API to update Sales Order Status

(1) ShareShare
ReportReport
Posted on by 163
Hi All,

We are using On-Prem Business central.

I want to create a custom API to update status of my sales order header.
I will send below JSON as request body.

{
  "OrderNo" : "10001",
  "Status" : "Open"
}

This API should update the Sales header status of 10001 No.
If anyone have any idea, please share or if you have any code snip you can share.

Thanks for your help.
I have the same question (0)
  • Suggested answer
    Mohamed Amine Mahmoudi Profile Picture
    26,811 Super User 2026 Season 1 on at
  • Verified answer
    Sami Ullah Profile Picture
    315 Moderator on at
    Hi,
    You can use the following link for API authentication:
     
     
    To make an API call in Postman, follow this guide:
    https://yzhums.com/6117/
     
    However, when updating the status, note that this field is read-only in Business Central. You will need to use a codeunit to update the status.
     
    Watch this video to understand how to call a codeunit:
    https://www.youtube.com/watch?v=onZav5n0zqk

    Example Codeunit:
    codeunit 50100 "SalesOrderProcessing"
    {
        Permissions = tabledata "Sales Header" = rimd;
        
        procedure UpdateSalesOrderStatus(orderno: Text[50]; status: Text[50]): Text
        var
            SalesOrder: Record "Sales Header";
        begin
            SalesOrder.Reset();
            SalesOrder.SetRange("Document Type", "Sales Document Type"::Order);
            SalesOrder.SetRange("No.", orderno);
            if SalesOrder.FindFirst() then begin
                case status of
                    'Open':
                        SalesOrder.Status := SalesOrder.Status::Open;
                    'Released':
                        SalesOrder.Status := SalesOrder.Status::Released;
                end;
                SalesOrder.Modify(true);
            end else
                exit('Sales Order not found.');
        end;
    }
    


    Example HTTP API Call
    POST /v2.0/{your tenantID}/Production/ODataV4/SalesOrderProcessing_UpdateSalesOrderStatus
    Host: api.businesscentral.dynamics.com
    Content-Type: application/json
    If-Match: *
    company: 2006d1d5-1a4e-ef11-bfe7-6045bde9c989  // your company ID
    Authorization: Bearer {Provide Token}
    
    {
        "orderno": "S-ORD101001",
        "status": "Released"
    }
    



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

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Women in Power Builds Momentum

Expanding mentorship, skilling, and AI innovation

Congratulations to the June Top 10 Community Leaders

These are the community rock stars!

Leaderboard > Small and medium business | Business Central, NAV, RMS

#1
OussamaSabbouh Profile Picture

OussamaSabbouh 580 Super User 2026 Season 1

#2
YUN ZHU Profile Picture

YUN ZHU 462 Super User 2026 Season 1

#3
Grigorios Mavrogeorgis Profile Picture

Grigorios Mavrogeorgis 272 Super User 2026 Season 1

Last 30 days Overall leaderboard

Featured topics

Microsoft Training Manuals

Product updates

Dynamics 365 release plans