OS1 Services
...
Integrate with Participants
How to: Implement Custom Code in Participant Services
8 min
implementing pre configured custom code 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 implementing custom code in the request body to dynamically modify the custom code config for each api call, we've added two attributes it can be used for creating, updating, and applying requests custom code fields to add custom code in the participant add the following values in the request body true false 0,0,211false left unhandled content type false left unhandled content type false left unhandled content type false left unhandled content type false left unhandled content type false left unhandled content type false left unhandled content type false left unhandled content type false left unhandled content type false left unhandled content type false left unhandled content type false left unhandled content type false left unhandled content type false left unhandled content type false left unhandled content type false left unhandled content type false left unhandled content type false left unhandled content type false left unhandled content type false left unhandled content type false left unhandled content type false left unhandled content type false left unhandled content type false left unhandled content type 📘 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 { "url" "https //www test com", "requestbody" {}, "requestheader" { "x coreos access" "{{token}}", "x coreos request id" "{{request id}}", "x coreos tid" "{{tenant id}}", "x coreos userinfo" { "id" "test1", "name" "customcode" } }, "method" "get", "wait" true, "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 { 	 } } 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 { "uniquecode" "code1", "name" "mobile", "owner" "delhivery", "properties" { "count" 10, "color" "blue" }, "callback" { "url" "http //examplecallback com" } } payload from custom code returned { "properties" { "count" 120 }, "callback" { "url" "https //delhivery test com/test", "meta" { "source" "coreos" } } } final payload that is used to register an instance { "uniquecode" "code1", "name" "mobile test", "owner" "delhivery", "properties" { "count" 120 }, "callback" { "url" "https //delhivery test com/test", "meta" { "source" "coreos" } } } restriction on fields in custom code response for 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 true falsefalse left unhandled content type false left unhandled content type false left unhandled content type false left unhandled content type false left unhandled content type false left unhandled content type false left unhandled content type false left unhandled content type false left unhandled content type false left unhandled content type false left unhandled content type false left unhandled content type how to retrieve custom code details in participant service 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