Remote service request and response format
In order for a remote service to communicate with Spark, it needs to use a standard request and response data format. If you are using a proxy service to intermediate the XConnector, it may need to be responsible for the data format.
Remote service request format
This section describes the format of the HTTP request that is sent from the Spark XConnector to the remote service. The HTTP request from Spark takes the form of a POST request containing headers and a request body.
Request headers
The header information typically appears to the remote service as a collection of key-value pairs. The HTTP request header should incorporate the Authorization key with a Bearer token.
Request body
The request body is a JSON object, presenting a set of name/value pairs (also termed a "dictionary"). A JSON array called inputs denotes the input records to pass to the remote service.
The JSON should follow the format prescribed in inputs definitions "Synchronous request of inputs using JSON arrays". Data type serialization is described in request_data.
{
"inputs": [
// ... array of the request data
]
}Example 1: Single value inputs
Submit details for a life insurance quotation.
age40sexMsmokingfalse
The first array in
inputsdefines the key names.The second array in
inputsdefines the value pairs.
Example 2: Table of inputs
Submit a table of vehicles for insurance quotes.
vehiclesMakeModelYearDodge
Viper
2017
Ford
F-150
2005
GMC
Blazer
2026
Example 3: Single and table inputs
Submit a table of vehicles and state for insurance quotes.
stateNYvehiclesMakeModelYearDodge
Viper
2017
Ford
F-150
2005
GMC
Blazer
2026
Remote service response format
This section describes the format of the HTTP response that is returned from the remote service to the Spark XConnector. The HTTP response from the remote service should take the form of a POST response containing headers and a response body.
Response body
This is very similar to the format described for the Request body. The JSON should follow the format prescribed in inputs definitions "Synchronous request of inputs using JSON arrays". Data type serialization is described in request_data.
The response body from the remote service encapsulates the serialized data, adhering to the following JSON structure:
outputs is a JSON array, where each element is a JSON array that represents one record of the response data. Outputs should follow the same structure denoted above for the Request body.
The first record defines the string keys.
Subsequent arrays can be returned corresponding to the processing of multiple records.
Warning messages can be returned from the remote service. It should be constructed with a JSON array containing a JSON array for every record of data with a warning. If a record does not have any warnings, return null.
Error messages can be returned from the remote service. They should be constructed with a JSON array containing a JSON array for every record of data with an error. If a record does not have any error, return null.
The process time is used to return the amount of calculation time needed for each row of data in milliseconds. Every successful execution to take at least 1 millisecond.
Example responses
HTTP 200 OK Content-Type: application/json
HTTP 200 OK Content-Type: application/json
HTTP 500 INTERNAL SERVER ERROR Content-Type: application/json
Last updated
