THE MOBILE PERSPECTIVE IN QUERY ODATA AND API
I initially found it difficult to implement complex interfaces between Business Central and Xamarin mobile apps by using ODATAv4 and API Pages.
Luckily Busines Central offers plenty of solutions to implement interfaces and both OData Bound and Unbound Actions are really awesome features.
One of common scenario I have to deal with is a mobile app showing sales prices, discounts and availability for a specific item for a customer.
In this situation, I prefer to leave to Business Central the logic to determine the right price and discount for the item because often this evaluation involves a custom logic implemented on BC side and the final price is not obtained as it would be with the standard.
Moreover with BC v16 a new logic and interface for price evaluation has been introduced and the “Sales Price” is now obsolete:
STEP 1: THE BUSINESS CENTRAL DATA UNBOUND ACTION
This is the sample codeunit with two different type of parameters.
In the first procedure I pass a generic JSON and then I deserialise it.
In the second procedure I pass direct parameters.
STEP 2: MAP THE CODEUNIT IN WEB SERVICES
The configuration may be managed via WSPublishing.xml.
STEP 3: TEST THE API WITH INSOMNIA
The POST for the two procedures:
The company is passed as an header parameters. May be passed in the URL too but I on my opinion the header solution is easier for Xamarin Forms implementation.
STEP 4: THE XAMARIN HTTP REQUEST
The Json input class:
This is the Business central JSON mapped in the C# class:
The Xamarin Forms Request with the company passed as http header.
Creating and Interacting with an OData V4 Unbound Action
Stefano Demiliani Dynamics 365 Business Central: using OData V4 Bound Actions
Codeunit API’s in Business Central
18th of April, 2021