How to: Work with subservices
Spark allows users to separate different groups of calculations into subservices. For example, imagine an Excel file that performs addition on one set of values and multiplication on another. Only one set of results is may be needed at a time. With subservices, the request can specify just one of the the operations instead of returning the addition and multiplication results every time.
Map the subservice
Syntax: Xinput_<subservice>.<parameter> and Xoutput_<subservice>.<parameter>
Follow the instructions to create a name in Define a named range in Excel for the selected range.
When creating the name, use the noted prefix defined in the syntax.
Example of mapping subservices


In this example, within the same Excel file there are 2 products being priced, ProductX and ProductY. These 2 products are separated into 2 subservices. Each subservice has 2 Xinputs, Age and Sex. Corresponding outputs need to be mapped for the ProductX and ProductY subservices.
Submit API requests for subservices
In the API Tester Adjust service parameters, there is a field to select subservices.
When a Spark services has no subservices, this field is blank.
When a Spark Service has subservices, the field initially contains Default.
Use the dropdown to select which subservices to include in the API call.
Spark filters the inputs and outputs based on the selected subservices.
Integrating to a subservice
To understand how to call a subservice, use the API Tester "Raw view" to review the parameters.
The selected subservices are included in the Execute API (v3) request_meta parameter
service_category.The
Defaultsubservice mentioned above is denoted as#Default#.
Find out more in the Parameters to control the response outputs of the Execute API (v3) request_meta.
Metadata subservice
The static meatdata subservice only works for Execute API (v3). It will calculate dynamically for Execute API (v4) and Batch APIs.
Syntax: Xoutput_metadata.<parameter>
Use the metadata subservice together with the Metadata API for static data (in other words, data that doesn't change when other inputs change). This subservice is much faster than using the full Execute API, since it does not perform any calculations.
The process to assign data to the metadata subservice is the same as in Map a single/multiple cell range to an input/output.
Spark stores this data separately from the Excel in a JSON file. The treatment of these outputs in the API Tester is the same as for other subservices.
Similar to Set default values for a calculation, if the metadata output contains a formula, Spark will evaluate it upon upload and save the value.
Any other subservices that depend on the reference will always use this calculated value.
The metadata subservice can also store and return images, see Return an image as a Base64 string.
Example file
Upload the example service to Spark to practice using subservices. Map the output cells for the two subservice inputs in the file and use the API tester to pick a subservice and control which values are returned. You can also map a range to a metadata output and see this feature in action.
Last updated
