OS1 Services
...
Dispatch Service
Integrate with Dispatch
How to: Implement Custom Code in Dispatch Service
6min
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 register custom code configurations docid\ dnkabqncd3ws7xxmb nnq 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 custom code docid\ mz ewp1umtozx39tr2n6k https //docs getos1 com/docs/custom code#section attributes it can be used for creating, updating, and applying requests custom code fields to add custom code in the dispatch service docid\ kjdpcl9yep5kbek1isxku 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 c 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 createdispatch\ onrequest, updatedispatch\ onrequest, updatedispatchstatus\ onrequest, updatedispatchsubstatus\ onrequest, addparticipant\ onrequest, removeparticipant\ onrequest, addparticipantbulk\ onrequest, addjob\ onrequest, removejob\ onrequest, removemultiplejobs\ onrequest, removejobfromdispatch\ onrequest, removemultiplejobsfromdispatch\ onrequest, addjobbyref\ onrequest, changestatusbyref\ onrequest, changesubstatusbyref\ onrequest, addmultiplejobsbyref\ onrequest, removemultiplejobsbyref\ onrequest, removejobbyref\ onrequest, addparticipantbyref\ onrequest, addmultipleparticipantsbyref\ onrequest, removeparticipantbyref\ onrequest, updatecustomdatabyref\ onrequest, patchcustomdatabyref\ onrequest, addjobbulk\ onrequest, createjob\ onrequest, updatecustomdata\ onrequest, patchcustomdata\ onrequest, updatejobstatus\ onrequest, updatejobsubstatus\ onrequest, custodyin\ onrequest, custodyout\ onrequest, custodyinbatch\ onrequest, custodyoutbatch\ onrequest, createdispatch\ onerror, updatedispatch\ onerror, updatedispatchstatus\ onerror, updatedispatchsubstatus, addparticipant\ onerror, removeparticipant\ onerror, addparticipantbulk\ onerror, addjob\ onerror, removejob\ onerror, removemultiplejobs\ onerror, removejobfromdispatch\ onerror, removemultiplejobsfromdispatch\ onerror, addjobbyref\ onerror, changestatusbyref\ onerror, changesubstatusbyref\ onerror, addmultiplejobsbyref\ onerror, removemultiplejobsbyref\ onerror, removejobbyref\ onerror, addparticipantbyref\ onerror, addmultipleparticipantsbyref\ onerror, removeparticipantbyref\ onerror, updatecustomdatabyref\ onerror, patchcustomdatabyref\ onerror, addjobbulk\ onerror, createjob\ onerror, updatecustomdata\ onerror, patchcustomdata\ onerror, updatejobstatus\ onerror, updatejobsubstatus\ onerror, custodyin\ onerror, custodyout\ onerror, custodyinbatch\ onerror, custodyoutbatch\ onerror 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 { "dispatchtype" "pudo", "dispatchref" "dsp 0001 0001", "tenantid" "delhivery", } payload returned from custom code { "customdata" { "facilityid" "facility 1", } } final payload that is used to register an instance { "dispatchtype" "pudo", "dispatchref" "dsp 0001 0001", "tenantid" "delhivery", "customdata" { "facilityid" "facility 1", } }