Business Central Web Services

Business Central Web Services: A Comprehensive Overview

Microsoft Dynamics 365 Business Central (BC) is a cloud-based enterprise resource planning (ERP) solution designed for small and medium-sized businesses. One of its most powerful features is its web services capabilities, which allow for seamless integration with other applications and services. This blog post delves into the intricacies of Business Central web services, focusing on the two primary protocols it supports: SOAP and OData.

Business Central Web Services

1. Understanding Web Services in Business Central

Web services are standardized ways of integrating web-based applications using open standards over an internet protocol backbone. In Business Central, web services enable the interaction with the application’s data and business logic from external applications. This interaction can be achieved using two primary protocols: SOAP (Simple Object Access Protocol) and OData (Open Data Protocol).

1.1 SOAP Web Services

SOAP is a protocol that allows programs running on different operating systems to communicate with each other. It uses XML to encode its messages and relies on other application layer protocols, most notably HTTP and SMTP, for message negotiation and transmission.

In Business Central, SOAP web services can be created from page and codeunit objects. The process involves exposing these objects through the Web Services setup page, where they can be published and accessed via a specific URL format:

“`
https://api.businesscentral.dynamics.com/v2.0///WS//Page/
“`

This URL structure allows external applications to perform operations such as reading, writing, and deleting data from Business Central.

1.2 OData Web Services

OData is a Microsoft-specific RESTful service that provides a standardized way to query and manipulate data. Unlike SOAP, OData uses a predefined format, making it easier to work with in various applications. OData services can be exposed using Page or Query objects, allowing for read and write operations on pages and read-only access on queries.

OData is widely supported across Microsoft products, including Excel, Power BI, and SharePoint, making it an attractive option for businesses looking to integrate Business Central with other Microsoft services.

 

2. Authentication Mechanisms

Accessing Business Central web services requires robust authentication mechanisms to ensure data security. Currently, the only supported method for accessing these services is through Azure-based authentication, specifically using OAuth with Microsoft Entra ID.

When a user attempts to access a web service, the Microsoft authentication server issues a security token after the user signs in. This token grants access to the Business Central server. It allows for secure data transmission between the user/service and Business Central.

To set up authentication, Business Central must be registered as a trusted application in Microsoft Entra ID. This ensures that only authorized users can access the web services.

 

3. Operations Supported by Business Central Web Services

Business Central web services support a variety of operations, enabling users to interact with the application’s data effectively. The operations available for SOAP and OData web services differ slightly, reflecting the capabilities of each protocol.

3.1 SOAP Operations

SOAP web services in Business Central support the following operations:

Create: Insert a single record.
CreateMultiple: Insert a set of records.
Delete: Delete a single record.
Delete_part Delete a subpage of a page result.
GetRecIdFromKey: Obtain a record ID from a key retrieved from a page result.
IsUpdated: Check whether an object has been updated since the key was retrieved.
Read: Read a single record.

These operations allow for comprehensive data manipulation. This makes SOAP a flexible option for developers looking to integrate Business Central with other systems.

3.2 OData Operations

OData web services provide a different set of operations, primarily focused on data retrieval and manipulation. The supported operations include:

POST: Used for creating new records (triggers OnInsert() and OnNewRecord()).
PATCH: Used for modifying existing records (triggers OnModify()).
DELETE: Used for deleting records (triggers OnDelete()).

OData also supports a variety of query options. This enables users to filter, sort, and paginate data effectively. This makes OData particularly useful for applications that require dynamic data retrieval and manipulation.

 

4. Working with OData Filters

When exposing a Business Central query as an OData web service, users can leverage OData filters to refine their data queries. The following are some common filter expressions:

Select a range of values: `$filter=Entry_No gt 610 and Entry_No lt 615`
And condition: `$filter=Country_Region_Code eq ‘US’ and Payment_Terms_Code eq ’30 DAYS’`
Or condition: `$filter=Country_Region_Code eq ‘ES’ or Country_Region_Code eq ‘US’`
Less than: `$filter=Entry_No lt 610`
Greater than: `$filter=Entry_No gt 610`
Contains: `$filter=contains(Name, ‘avi’)`

These filters allow developers to create highly efficient queries. This ensures that only relevant data is retrieved from Business Central.

 

5. Best Practices for Using Business Central Web Services

To maximize the effectiveness of Business Central web services, consider the following best practices:

Use OData for New Integrations: – Given that SOAP page objects are set to be deprecated in future versions of Business Central, it is advisable to use OData for new integrations. OData provides a more modern and flexible approach to data access.

Implement Robust Authentication: – Ensure that your application is securely authenticated using OAuth with Microsoft Entra ID. This protects sensitive data and ensures that only authorized users can access the web services.

Optimize Queries: – Utilize OData filters to optimize data retrieval. This reduces the amount of data transferred over the network and improves application performance.

Monitor API Usage: – Keep track of API usage to identify any potential bottlenecks or performance issues. This can help in scaling your application as needed.

Stay Updated with Changes:- Regularly check for updates and changes in Business Central web services. This is especially important regarding deprecated features and new capabilities.

 

6. Conclusion

Business Central web services provide a powerful means of integrating and interacting with the Business Central ERP system. By leveraging SOAP and OData protocols, along with secure OAuth 2.0 authentication, businesses can create robust applications that enhance their operational efficiency. Understanding the capabilities and best practices associated with these web services is crucial for developers and businesses looking to maximize their use of Business Central.

As the landscape of web services continues to evolve, staying informed about the latest developments will ensure that businesses can effectively harness the power of Business Central for their unique needs.

Do you like to read more educational content? Read our blogs at Cloudastra Technologies or contact us for business enquiry at Cloudastra Contact Us

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top