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...
Suggested Answer

Reduce API Response Time.

(5) ShareShare
ReportReport
Posted on by 268
Hi All,
 
I have created a Codeunit to modify data in Business Central from a third-party application via API integration. The Codeunit follows these steps:
  1. Validate if the Sales Order No. is blank.
  2. Check the Sales Order status; if the status is open, the Sales Order is allowed to be edited in the third-party application.
  3. Delete staging data in the Instrument Sales Header and Instrument Sales Line tables based on the Sales Order No.
  4. After deleting existing data, re-enter the data based on the JSON object.
  5. Once the staging tables are updated, modify data in the Sales Header and Sales Line tables based on the Sales Order No.
  6. After updating the Sales Header and Sales Line tables, automatically send the Sales Order for approval.
The Codeunit is working, but the API response time is currently too high—it takes about 5.25 seconds. After some optimizations, the response time has been reduced to 4.34 seconds.
 
I want the response to be in milliseconds, ideally less than 1 second. Please check the attached file of AL code and advise.
 
I have the same question (0)
  • Suggested answer
    Steven Renders Profile Picture
    5,698 Moderator on at
  • Suggested answer
    Sohail Ahmed Profile Picture
    11,177 Super User 2026 Season 1 on at
  • Suggested answer
    Ramesh Kumar Profile Picture
    7,566 Super User 2026 Season 1 on at

    use an async API pattern for “sub-second” For true <1s: accept the payload, enqueue work, return 202 Accepted, and process in a background session. That’s the standard web API guidance—and BC supports background sessions

    https://businesscentralgeek.com/how-to-run-background-processes-in-business-central-startsession?utm

     

    Thanks, Ramesh

    If this was helpful, please check the "Does this answer your question?" box and mark it as verified.

     

  • Suggested answer
    Khushbu Rajvi. Profile Picture
    22,792 Super User 2026 Season 1 on at
  • Suggested answer
    Sumit Singh Profile Picture
    11,799 Super User 2026 Season 1 on at
    Hi, 
     
    To optimize your Codeunit for API integration in Business Central and reduce response time, here are few strategies and official Microsoft resources:

    Official Microsoft Learn Links

    1. Performance for Developers [2]
    2. Web Service Performance [1]
    3. OData/API Client Performance [3]
    4. API Limits and Throttling [4]

    Optimization Tips

    • Avoid temp tables for large datasets; they slow down performance.
    • Use API pages or queries instead of UI pages for web service endpoints.
    • Batch operations using $batch to reduce multiple calls.
    • Limit data using $filter, $top, and $select to reduce payload.
    • Avoid parallel inserts for child records under the same parent.
    • Use unbound actions for Codeunit procedures exposed via OData.
    • Split long-running requests and implement retry logic for throttling.

    Mark the Boolean true “Does this answer your Question” if this was Helpful.
     

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 Launch!

Jump in, show your community spirit, and win prizes!

Women in Power Builds Momentum

Expanding mentorship, skilling, and AI innovation

Congratulations to the May Top 10 Community Leaders

These are the community rock stars!

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

#1
OussamaSabbouh Profile Picture

OussamaSabbouh 1,960 Super User 2026 Season 1

#2
YUN ZHU Profile Picture

YUN ZHU 1,299 Super User 2026 Season 1

#3
Grigorios Mavrogeorgis Profile Picture

Grigorios Mavrogeorgis 1,131 Super User 2026 Season 1

Last 30 days Overall leaderboard

Featured topics

Microsoft Training Manuals

Product updates

Dynamics 365 release plans