OS1 Services
...
How to use Entities?
How to: Implement Custom Code in Entity Service
7 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 entitytypepluralname 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 docid\ aybe70hu6gdjh5mpverll it can be used for creating, updating, and applying requests custom code fields to add custom code in the docid\ aybe70hu6gdjh5mpverll add the following values in the request body true left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type 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" "vehicle", "owner" "delhivery", "properties" { "count" 10, "color" "blue" }, "callback" { "url" "http //www 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" "vehicle", "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 few restrictions as to what data keys are not acceptable for particular api types we have provided the list below for the developers to know more true left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type