{"title":"Web services performance","url":"https://jonas-paprotka.de/docs/dev-itpro/webservices/web-service-performance/","by":"JOP-AL","license":"Copyright (c) Microsoft Corporation. CC BY 4.0, https://creativecommons.org/licenses/by/4.0/; code samples MIT. From https://learn.microsoft.com/en-us/dynamics365/business-central/dev-itpro/webservices/web-service-performance, MicrosoftDocs/dynamics365smb-devitpro-pb at 828b6ee (2026-11-19). Changed: includes filled in, links to this site, and for agents shortened without dropping a fact.","credit":"Microsoft Corporation, CC BY 4.0","origin":"https://learn.microsoft.com/en-us/dynamics365/business-central/dev-itpro/webservices/web-service-performance","source":{"name":"Business Central developer and IT pro docs","repo":"https://github.com/MicrosoftDocs/dynamics365smb-devitpro-pb","commit":"828b6ee72fcd75755627cd6011f3d20899217ab2","date":"2026-11-19"},"checked":"2026-11-19","description":"Learn about how performance of Business Central web services (OData, API, and SOAP)","date":"2023-07-03","meta":{"topic":"article"},"outline":[{"level":2,"title":"General anti-patterns (don't do this)","slug":"general-anti-patterns-dont-do-this","at":208,"chars":2181},{"level":2,"title":"General performance patterns (do this)","slug":"general-performance-patterns-do-this","at":2389,"chars":1353},{"level":2,"title":"API/OData client performance patterns","slug":"apiodata-client-performance-patterns","at":3742,"chars":427},{"level":2,"title":"Power BI Performance patterns","slug":"power-bi-performance-patterns","at":4169,"chars":3442},{"level":2,"title":"How to handle large throughput of web service calls","slug":"how-to-handle-large-throughput-of-web-service-calls","at":7611,"chars":1800},{"level":2,"title":"Outgoing web service calls block AL execution","slug":"outgoing-web-service-calls-block-al-execution","at":9411,"chars":1211},{"level":2,"title":"Web service telemetry","slug":"web-service-telemetry","at":10622,"chars":397},{"level":2,"title":"Related information","slug":"related-information","at":11019,"chars":343}],"text":"The performance of web services (OData, API, and SOAP) is both the responsibility of the Business Central server endpoint and the consumer (the client). In this article, you can learn more about both topics.\n## General anti-patterns (don't do this)\n Avoid using standard UI pages to expose as web service endpoints. Many things, such as fact boxes aren't returned in web service results, but use resources to prepare. Things that have historically caused performance issues on pages that are exposed as endpoints are:\n   Heavy logic in OnAfterGetCurrRecord or OnAfterGetRecord\n   Many SIFT fields\n   FactBoxes\n Avoid exposing calculated fields, because calculated fields are expensive. Try to move them to a separate page or to refactor the code so the value is stored on the physical table (if applicable). Complex types are also a performance hit because they take time to calculate.\n Don't use temp tables as a source if you have many records. Temp tables that are based on APIs are a performance hit. The server has to fetch and insert every record, and there's no caching on data in temp tables. Paging becomes difficult to do in a performant manner. A rule of thumb is if you have more than 100 records, don't use temp tables.\n Don't insert child records belonging to same parent in parallel. This condition causes locks on parent and Integration Record tables because parallel calls try to update the same parent record. The solution is to wait for the first call to finish or use $batch, which will make sure calls get executed one after another.\n Don't use a deprecated protocol such as SOAP. Instead, utilize newer technology stacks such as OData, or preferably API pages/queries. The latter are up to 10 times faster than using the SOAP protocol.\nIf you're migrating a SOAP integration that calls codeunit procedures, consider OData V4 unbound actions for supported procedure signatures. See Create and call an OData V4 unbound action<../developer/devenv-creating-and-interacting-with-odatav4-unbound-action>.\nWhen reading data from API queries, the use of aggregation methods can affect performance. Don't define this method if you intend to read data on the highest granularity of the underlying table (for example, the entry no. on G/L Entries). While the method property is meaningful for aggregated data, it slows down the performance in context of detailed level queries.\n## General performance patterns (do this)\n Instead of exposing UI pages as web service endpoints, use the API pages or API queries because they've been optimized for this scenario. Select the highest API version available. Don't use the beta version of the API pages. To read more about API pages, see API Page Type<../developer/devenv-api-pagetype>.\n If you do expose UI pages as web service endpoints, then triggers must be run for all records returned from the Business Central server. As a developer, you must make your AL code conditional on the ClientType. Specifically, avoid updating FactBoxes, avoid calculation, and avoid defaulting logic. See ../developer/methods-auto/system/system-guiallowed-method.\n The choice of protocol (SOAP, OData, or APIs) for the endpoint can significantly affect performance. Favor OData version 4 or APIs for the best performance. You can expose procedures in a codeunit as an OData endpoint by using unbound actions. See Create and call an OData V4 unbound action<../developer/devenv-creating-and-interacting-with-odatav4-unbound-action>.\n If you want OData endpoints that work as data readers (like for consumption in Power BI), consider using API queries and set `DataAccessIntent = ReadOnly`. See API Query Type<../developer/devenv-api-querytype> and ../developer/properties/devenv-dataaccessintent-property.\n## API/OData client performance patterns\nWhen calling APIs and OData web services, there are many strategies that you can use to speed up your queries, like:\n Limiting the set ($filter or $top) if you're using an expensive $expand statement\n Using OData transaction $batch\n Using Data Access Intent Read-only with OData\nFor more information about OData query performance, see OData Query Performance<odata-client-performance>.\n## Power BI Performance patterns\nWhen calling APIs and OData web services from Power BI, it's important that you understand the concepts of query folding. The Business Central connector uses the https://learn.microsoft.com/powerquery-m/odata-feed library behind the scenes, which translates numerous the Power BI constructs into OData query parameters. For example:\n Table.RemoveColumns or Table.SelectColumns becomes $select\n Table.SelectRows becomes $filter\n Table.ExpandTableColumn becomes $expand\nThe following example illustrates how filters are pushed from Power BI to the Business Central connector.\nIt is common practice to have a query that refreshes the current date and time at every refresh in your Power BI dataset:\n```powerquery-m\n// LastRefreshDate query\nlet\n    Source = DateTimeZone.UtcNow()\nin\n    Source\n```\nTo apply a filter such as \"the last 12 months of data\" to other queries, simply use the PowerQuery _Table.SelectRows_ on appropriate dates, for example:\n```powerquery-m\n// SalesInvoices\n// Filtered to last 12 months\nlet\n    Source = Dynamics365BusinessCentral.ApiContentsWithOptions(null, null, null, null),\n    PRODUCTION = Source{[Name=\"PRODUCTION\"]}[Data],\n    #\"CRONUS USA, Inc.\" = PRODUCTION{[Name=\"CRONUS USA, Inc.\"]}[Data],\n    v2.0 = #\"CRONUS USA, Inc.\"{[Name=\"v2.0\"]}[Data],\n    salesInvoices_table = v2.0{[Name=\"salesInvoices\",Signature=\"table\"]}[Data],\n    filteredRows = Table.SelectRows(salesInvoices_table, each [postingDate] > Date.From(Date.AddMonths(LastRefreshDate, -12)))\nin\n    filteredRows\n```\nFor a LastRefreshDate of _2022-08-17_, the Power BI connector adds this `$filter` predicate to the API call:\n`/v2.0/PRODUCTION/api/v2.0/salesInvoices?$filter=postingDate gt 2022-08-17&company=CRONUS USA, Inc.`\nFor more information about query folding in Power BI, see https://learn.microsoft.com/power-query/power-query-folding.\n> NOTE\n> Query folding optimizations might not be applied in a few cases:\n > Query folding is NOT applied when loading data preview (such as while you are editing your query and data updates in the query editor screen).\n > Be careful if you do joins with other data in Power Query. If you do, some OData.Feed limitations might apply, and the OData parameters will be applied client side instead. The Workaround from the Power BI team is to use Table.Buffer before doing any join. For more information, refere to Known issues and limitations in OData-based Power BI connectors<https://learn.microsoft.com/power-query/connectors/odata-feed#joins>.\nFor more information about OData/API client performance in Business Central, see OData query performance<odata-client-performance>.\nWhen refreshing a query in a Power BI semantic model, you might experience an error such as `DataSource.Error: OData: Unable to read data from the transport connection: existing connection was forcibly closed by the remote host.` This error can happen either when the query refresh was interrupted by a transient error (in this case, just implement a retry) or if the query can't finish within the limit defined for web service calls on the Business Central server. In the latter case, the Business Central server will cancel the call. If this happens consistently, you need to tune your query, either by applying data filters, by reducing the number of columns (do you use all of them?), or maybe by partitioning the table (using custom partitioning through the XMLA endpoint for the model).\n## How to handle large throughput of web service calls\nWhen integrating to Business Central from external systems using web services, it's important to understand the operational limits for the Business Central servers that host the web service endpoints being called. To ensure that excessive traffic doesn't cause stability and performance issues for all users, the online version of Business Central server has set up throttling limits on web service endpoints.\nMake sure that your external application can handle the three HTTP status codes 429 (Too Many Requests), 503 (Service Temporarily Unavailable), and 504 (Gateway Timeout).\n Handling status codes 429 and 503 requires the client to adopt a retry logic while providing a cool off period. You can apply different strategies, like:\n   Regular interval retry\n   Incremental intervals retry\n   Exponential back-off\n   Randomization\n Handling status code 504 - Gateway Timeout requires the client to refactor the long running request to execute within time limit by splitting the request into multiple requests. Then, deal with potential 429 codes by applying a back off strategy.\nA common pattern is to implement a queue in your external application so that you can flatten spikes of traffic. If a request gets the HTTP status code 429 (Too Many Requests) or 503 (Service Temporarily Unavailable), then put it back in the queue and apply one of the retry strategies described previously.\nRead more about web service limits, see Working with API limits in Dynamics 365 Business Central<../api-reference/v2.0/dynamics-rate-limits>.\nThe same advice applies for outgoing web service calls using the AL module HttpClient. Make sure your AL code can handle slow response times, throttling, and failures in external services that you integrate with.\n## Outgoing web service calls block AL execution\nIf you call an external web service using the HttpClient module in AL, be aware that the Business Central Server blocks the execution of AL code for the session until the call completes. For interactive sessions, this behavior means that the user sees a spinning wheel during the call.\nIf you have enabled telemetry for your environment or app, you can use this KQL query to analyze how much time users are delayed in the UI by calls to external services.\n```kusto\ntraces\n| where customDimensions has 'RT0019'\n| where customDimensions.clientType == 'WebClient'\n| extend executionTimeInMs = toreal(totimespan(customDimensions.serverExecutionTime))/10000 //the datatype for executionTime is timespan\n| summarize count() // how many calls\n, sum(executionTimeInMs) // sum of delays for UI sessions\n, avg(executionTimeInMs) // average waiting time by this app\n, max(executionTimeInMs) // average waiting time by this app\nby\n// which app is calling out from the UI\n  extensionPublisher = tostring( customDimensions.extensionPublisher )\n, extensionName = tostring( customDimensions.extensionName )\n, extensionVersion = tostring( customDimensions.extensionVersion )\n```\n## Web service telemetry\nAll incoming calls to Business Central web services and outgoing calls to external services are logged to partner telemetry. Telemetry enables you to monitor which endpoints are being used and the category of the web service, like SOAP, OData, or API. You can also see possible failures, which are tracked in the HTTP status codes for the calls.\nSee web-service-telemetry\n## Related information\nWeb Services Overview<web-services>\nweb-services-best-practices\nweb-service-telemetry\nAnalyzing Incoming Web Services Request Telemetry<../administration/telemetry-webservices-trace>\nTroubleshooting web service errors<web-service-troubleshooting>\nPerformance Articles For Developers<../performance/performance-developer>"}