Today we see how to make custom API in business central.
I ma making API for Item data.
Step 1:
add new file in project and set the any name.al Write the below code in the file.
page 50103 Products
{
PageType = Card;
SourceTable = Item;
layout
{
area(Content)
{
group(GroupName)
{
field("No."; Rec."No.") { }
field(Description; Rec.Description) { }
field(Blocked; Rec.Blocked) { }
field(Type; Rec.Type) { }
field("Base Unit of Measure"; Rec."Base Unit of Measure") { }
field("Last Date Modified"; Rec."Last Date Modified") { }
}
}
}
}
Step 2: Add new file in the project and set the name.xml. In file write twebservices and click enter you will automatically get the structure.
<?xml version="1.0" encoding="UTF-8"?>
<ExportedData>
<TenantWebServiceCollection>
<TenantWebService>
<ObjectType>Page</ObjectType>
<ServiceName>Products</ServiceName>
<ObjectID>50103</ObjectID>
<Published>true</Published>
</TenantWebService>
</TenantWebServiceCollection>
</ExportedData>
Step 3: Now run the project it automatically publish your api.
Step 4: Search web service in business central search bar and click on it.
Step 5: You can see the webservice in the below image.
In the next post we will look at how we use our API on postman.