> For the complete documentation index, see [llms.txt](https://docs.coherent.global/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.coherent.global/xconnector/how-to-connect-to-an-xconnector-service.md).

# 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:

1. Review the assets and components needed to complete this how to, including the remote external service.
2. Call the remote `Xconnector` service.
3. Create a Spark Service with a sample `XConnector` Excel. Once uploaded to the Coherent Spark platform, it enables integration to this remote service.
4. Consume `XConnector` from Excel\
   Use the model via [Coherent Assistant](/coherent-assistant.md) in the Excel application or Microsoft 365.

## Review the assets and components

|                                     |                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              |
| ----------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| Remote service                      | <p>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 <a href="https://func-xconnector-sample.azurewebsites.net/api/species"><https://func-xconnector-sample.azurewebsites.net/api/species></a>.<br><br>If you are interested in creating your own <code>XConnector</code> see: <a data-mention href="/pages/CcbQ7RRe6egNYbEGGyst">/pages/CcbQ7RRe6egNYbEGGyst</a>. The code for this <code>XConnector</code> is also attached below.</p> |
| `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.                                                                                                                                                                                                                                                                                                                                                                                                                             |

{% file src="/files/n0qw8s1du2paao0zahPq" %}

{% file src="/files/iWJbcIkdDYPqsBPeO8ap" %}

{% file src="/files/Ob5pGYtpncheQcIC0Tdd" %}

## Call the remote `XConnector` service

In the `species` remote service, we provide a list of animal `species` `Type`s and we will receive a list of matching animal `name`s, `type` and `countries`.

1. Run the curl statement in your application of choice. The user guide includes instructions on using [Postman](/integrations/postman.md). Note the request body follows the "table of inputs" format from [Remote service input and output data formats](/xconnector/remote-service-input-and-output-data-formats.md#request-format-from-spark-xconnector-to-remote-service).

   ```sh
   curl --location 'https://func-xconnector-sample.azurewebsites.net/api/species' \
   --header 'Content-Type: application/json' \
   --data '{
     "inputs": [
       ["species"],
       [
         [
           ["Type"],
           ["Reptile"]
         ]
       ]
     ]
   }'
   ```
2. You should receive this sample response. It conforms to the structure in [Remote service input and output data formats](/xconnector/remote-service-input-and-output-data-formats.md#response-format-from-the-remote-service-to-spark-xconnector).

   ```sh
   curl --location 'https://func-xconnector-sample.azurewebsites.net/api/species' \
   --header 'Content-Type: application/json' \
   --data '{
     "inputs": [
       ["species"],
       [
         [
           ["Type"],
           ["Reptile"]
         ]
       ]
     ]
   }'
   ```

## Create a Spark service with the remote service call

1. If you have not created a Spark service before, please review [Get started in 5 minutes](/getting-started-in-5-minutes.md).
2. Open the `species.xlsx` file that is attached above. From the Named Ranges, in addition to `Xinput_types` and `Xoutput_results`, this file also includes important named ranges to identify this as a `XConnector` service.

   | Named range                       | Description                                                               | Example value                                                                                          |
   | --------------------------------- | ------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------ |
   | `XPROPERTY_DefaultEngineType`     | The engine type for the model — must be set to `XConnector`.              | <p><code>XConnector</code><br><br>This entry is case sensitive. The <code>C</code> is capitalized.</p> |
   | `XPROPERTY_XConnectorTargetUrl`   | The base URL of the remote service endpoint (must end with `/`).          | `https://func-xconnector-sample.azurewebsites.net/api/`                                                |
   | `XPROPERTY_XConnectorServiceName` | The specific service name (matches the endpoint name after the base URL). | `species`                                                                                              |
3. In Spark, create a folder called `xconnectors`.
4. Upload this Excel into the `xconnectors` folder as a Spark service. Keep the name of the service as `species`.
5. If you upload this Spark and use the [API Tester](/navigation/api-tester.md) to make an API call, you should see that the response includes a list of matching animal `name`s.

## Consume the `XConnector` from Excel

This step requires [Coherent Assistant](/coherent-assistant.md) to be installed and available in your Excel account.

1. Open the `species-xcall.xlsx` workbook that is attached above.
2. Open [Coherent Assistant](/coherent-assistant.md).
3. Log in to the Spark tenant where your `XConnector` service was deployed.
4. Coherent Assistant will automatically detect the `XConnector model` and allow you to run it directly within Excel.
5. The `Xcall` function is used to pull the data from the `XConnector`. Learn more about `Xcall` in [Call Spark service APIs (Xcall)](/build-spark-services/call-spark-service-apis.md).
   1. If you had instead uploaded the `species` to another folder `more_xconnnectors`, change the `service` reference in the `CS.SPARK_XCALL()` function to point to `"more_xconnectors/species"`.
   2. Within the formula there are the parameters `"!treat_as_table","type"`, this is needed because the animal `type`s are in a single column. If single cell inputs or multi-column tables are used, then these parameters are not needed.
6. If you create a Spark service from this workbook by adding `Xinput` and `Xoutput`, then you can create additional logic and calculations around the `species` remote service that can be used in an integration, e.g. return the number of matching animals.
