편집

다음을 통해 공유


Using OData Web Services to Modify Data

You can write to the Business Central database using an OData web service that exposes a writable page. For example, you can expose a page as an OData web service and implement it in a portal that is based on Microsoft SharePoint Online. Users of the portal can then modify the data.

Modifying Data Using OData Web Services

If an editable page is exposed as a web service, the data in the underlying table can be accessed and modified by an OData call. Business Central supports the following OData operations for modifying data.

OData call Data impact Triggers run on page and table in Business Central
POST Creates a new entity. OnNewRecord and OnInsert
PATCH Modifies the specified existing entity. OnModify
DELETE Deletes the specified existing entity. OnDelete

All calls fail if the user does not have the relevant permissions, and if the relevant property on the page, InsertAllowed, ModifyAllowed, or DeleteAllowed, is set to No.

You can use an OData web service in applications where you want users to be able to modify Business Central data the Business Central Web client. For example, you can show fields from the Customer table on a mobile device or in a browser so that a user can create, update, or delete customers in the Business Central database.

For PATCH operations

PATCH operations require the 'If-Match' header to be set, either with a retrieved ETag or with '*'.

Note

PATCH is not possible for collection properties in OData. This is not a limitation imposed by Business Central but is specified in section 11.4.9.4 of the OData v4 standard.

Company-Specific and Tenant-Specific OData Calls

In your implementation of the web service, you can specify which company in the database that a user can write to in the URIs that expose the web services. Similarly, you can specify the specific tenant that the change applies to if the database handles more than one tenant.

If you do not specify a company, Business Central will identify a default company. The default company is found in the following order of sequence:

  1. The ServicesDefaultCompany setting in the Tenants.config file.

  2. The ServicesDefaultCompany setting in the CustomSettings.config file for Business Central Server.

  3. The company in the current tenant when there is only one company.

    If the OData request is for modifying metadata, Business Central will return the first company in the tenant database because metadata applies to all companies in the database.

If no default company can be found based on the criteria, an error message appears.

See Also

Known OData limitations
OData Web Services
Using OData to Return-Obtain a JSON Document