A developer has created a custom API named contoso_CalculateDiscount with a request parameter CustomerTier and a response property DiscountPercent. A plug-in class containing the calculation is already registered. How should the developer connect the plug-in to the custom API so it runs as the main operation and returns the result?
Select an answer to reveal the explanation.
Short Explanation
Point the custom API at your plug-in type and it becomes the engine, no step needed. Inputs arrive in InputParameters, and you hand results back through OutputParameters. The trap is reaching for Target or images; those are for table messages, not your custom contract.
Full Explanation
A custom API links to its main operation logic through the PluginTypeId column, which references a registered plug-in type. When the API is called, Dataverse runs that type in the main operation stage without a separately registered step. Request parameter values arrive in the execution context's InputParameters collection under their unique names, so the code reads CustomerTier there, and the plug-in sets response properties by writing to OutputParameters using the response property's unique name, so DiscountPercent is returned to the caller. Registering a PreOperation step instead would run code before the main operation, and SharedVariables carry data between plug-ins rather than request inputs; writing to a Target entity has no meaning for a global custom API that has no Target. Setting the plug-in type correctly but reading from Target and writing to PostEntityImages confuses the custom API contract with table messages; images are snapshots of table rows and are not returned to callers. A PostOperation step can read InputParameters, but writing the result to Target does not populate the response, and this pattern is a workaround reserved for cases such as passing configuration data. Exam caveat: without a plug-in type the API still runs and returns default values for its response properties. Operational check: call the API through the Web API and confirm that the response body contains DiscountPercent with the calculated value.