How to: Connect to an XConnector service
This article walks through the process of connecting to a sample XConnector Spark service. In this guide we go through the following steps:
Review the assets and components needed to complete this how to, including the remote external service.
Call the remote
Xconnectorservice.Create a Spark Service with a sample
XConnectorExcel. Once uploaded to the Coherent Spark platform, it enables integration to this remote service.Consume
XConnectorfrom Excel Use the model via Coherent Assistant in the Excel application or Microsoft 365.
Review the assets and components
Remote service
An Azure HTTP-triggered Function that allows anonymous access. It retrieves a filtered list of species based on the input criteria provided in the request. The function is hosted at https://func-xconnector-sample.azurewebsites.net/api/species.
If you are interested in creating your own XConnector see: . The code for this XConnector is also attached below.
species.xlsx Excel workbook
The sample Spark model file that defines the inputs, outputs, service type (XConnector), and the URL to the remote service.
species-xcall.xlsx Excel workbook
A sample Excel workbook that consumes the species service directly via XConnector. It can be used in the Excel application or Microsoft 365.
Call the remote XConnector service
XConnector serviceIn the species remote service, we provide a list of animal species Types and we will receive a list of matching animal names, type and countries.
Run the curl statement in your application of choice. The user guide includes instructions on using Postman. Note the request body follows the "table of inputs" format from Request format from Spark XConnector to Remote service.
You should receive this sample response. It conforms to the structure in Response format from the Remote service to Spark XConnector.
Create a Spark service with the remote service call
If you have not created a Spark service before, please review Get started in 5 minutes.
Open the
species.xlsxfile that is attached above. From the Named Ranges, in addition toXinput_typesandXoutput_results, this file also includes important named ranges to identify this as aXConnectorservice.Named rangeDescriptionExample valueXPROPERTY_DefaultEngineTypeThe engine type for the model — must be set to
XConnector.XConnectorThis entry is case sensitive. TheCis capitalized.XPROPERTY_XConnectorTargetUrlThe base URL of the remote service endpoint (must end with
/).https://func-xconnector-sample.azurewebsites.net/api/XPROPERTY_XConnectorServiceNameThe specific service name (matches the endpoint name after the base URL).
speciesIn Spark, create a folder called
xconnectors.Upload this Excel into the
xconnectorsfolder as a Spark service. Keep the name of the service asspecies.If you upload this Spark and use the API Tester to make an API call, you should see that the response includes a list of matching animal
names.
Consume the XConnector from Excel
XConnector from ExcelThis step requires Coherent Assistant to be installed and available in your Excel account.
Open the
species-xcall.xlsxworkbook that is attached above.Open Coherent Assistant.
Log in to the Spark tenant where your
XConnectorservice was deployed.Coherent Assistant will automatically detect the
XConnector modeland allow you to run it directly within Excel.The
Xcallfunction is used to pull the data from theXConnector. Learn more aboutXcallin Call Spark service APIs (Xcall).If you had instead uploaded the
speciesto another foldermore_xconnnectors, change theservicereference in theCS.SPARK_XCALL()function to point to"more_xconnectors/species".Within the formula there are the parameters
"!treat_as_table","type", this is needed because the animaltypes are in a single column. If single cell inputs or multi-column tables are used, then these parameters are not needed.
If you create a Spark service from this workbook by adding
XinputandXoutput, then you can create additional logic and calculations around thespeciesremote service that can be used in an integration, e.g. return the number of matching animals.
Last updated
