How to: Implement Custom Code in Participant Services
- The pre-configured Custom Code URL is available for each API that supports Custom Code. The Custom Code will be registered and configured for a type - Like ParticipantTypePluralName.
- Developers can configure the Custom Code for - Create Instance, Update Instance, and Apply Event.
- It can be used for creating, updating, and applying requests.
To add custom code in the Participant add the following values in the request body:
Name | Type | Description |
---|---|---|
url | string | Request URL for the Custom Code API call. |
requestHeader | object | Default headers for Custom Code API call. |
method | string | HTTP method - Type of API request for custom code (POST/PUT/GET) |
wait | boolean | Wait for the response from the API call |
acceptableStatusCodes | array | Acceptable status codes. |
raiseErrorOnStatusMismatch | boolean | Raise an error if the status code returned doesn’t match acceptableStatusCodes. |
methodName** | string | Type of action (for create, update, or apply) and onRequest or onError |
📘 methodNames allowed are - create:OnRequest, create:OnError, update:OnRequest, update:OnError, apply_event:OnRequest, apply_event:OnError
Here is a sample payload of Custom Code with methodName apply_event:OnRequest :
Expected Response From Custom Code
Data is expected in response to the Custom Code with the existing payload in the data fields.
Data Formation from Custom Code Response
The fields returned from Custom Code inside the data field are replaced with the existing payload as shown below.
The Payload in Request Body
Payload from Custom Code returned
Final Payload that is used to register an instance
Restriction on Fields in Custom Code ResponseFor different APIs in Custom Code, there are a few restrictions on what Data keys are not acceptable for particular API types. We have provided the list below for the developers to know more.
Here is the markdown table:
API Type | Values not accepted in Data keys | Values accepted in Data keys |
---|---|---|
Create Instance | uniqueCodeOwnerappIdentityTypePluralNamet | PropertiesCallbackCategorySubCategory |
Update Instance | uniqueCodeOwnerappIdentityTypePluralName | PropertiesCallback |
Apply Event | uniqueCodeOwnerappIdentityTypePluralName | eventCodereasonCode |
To retrieve the details of the configured Custom Code in Participant Service, call the GET Custom Code Configuration endpoint and pass the Custom Code ID in the path parameter.