---
schema_version: "1"
id: eba3338c94975db70415263de0d069ad9dd1e42cf10dc561c5dc0d7d5f6367cc
title: Salesforce Commerce Cloud B2C Data Connector Examples
collection: mulesoft
version: current
locale: en-us
portal_url: https://docs.salesforce.com/mulesoft/current/en-us/commerce-cloud-b2c-data-connector/latest/commerce-cloud-b2c-data-connector-examples.md
canonical_url: https://docs.mulesoft.com/commerce-cloud-b2c-data-connector/latest/commerce-cloud-b2c-data-connector-examples
source_site: docs.mulesoft.com
content_type: documentation
content_hash: 0002cfe67629f559415dd7462853b61b4ef43f5c21fdce9208f06328b43daac8
description: MuleSoft Documentation Site
release: "1.0"
latest: true
---
---
product: Salesforce Commerce Cloud B2C Data Connector
version: 1.0
is-latest-version: true
---

# Salesforce Commerce Cloud B2C Data Connector Examples

> For the full documentation index, see: https://docs.mulesoft.com/llms.txt

This example shows how to execute a search for assignments and get the search results.

This image shows the assignment search example flow:

![Search assignment flow with HTTP Listener, Assignment Search operation, and Error handling](/mulesoft/current/en-us/commerce-cloud-b2c-data-connector/latest/_images/data-connector-assignments-search-flow.jpg)

## Configure the HTTP Listener Source

In Studio, create a new Mule project in which to add and configure the source for the connector:

1.  In Studio, select **File > New > Mule Project**.

2.  Enter a name for your Mule project and click **Finish**.

3.  In the **Mule Palette** view, select **HTTP > Listener**.

4.  Drag **Listener** to the Studio canvas.

5.  On the **Listener** configuration screen, optionally change the value of the **Display Name**
    field.

6.  Specify `/assignmentsSearch` for the **Path** field.

    ![HTTP Listener General configuration example values](/mulesoft/current/en-us/commerce-cloud-b2c-data-connector/latest/_images/data-connector-http-listener-config.jpg)

7.  Click the plus sign (**+**) next to the **Connector configuration** field to configure a global
    element that can be used by all instances of the HTTP listener in the app.

    1.  On the **General** tab, enter `8081` in **Port**.

    2.  Click **Test Connection**.

    3.  Click **OK**.

8.  Save the Mule project. .

## Configure the Assignments Search Operation

1.  From the **Mule Palette** view, select the **Assignment Search** operation from the palette and
    drag it on to the flow.

2.  Navigate to `http://localhost:8081/assignmentsSearch`, open Postman, and copy the required body
    for the **Assignments Search** operation:

    ![Assignments Search operation example Content body](/mulesoft/current/en-us/commerce-cloud-b2c-data-connector/latest/_images/data-connector-assignment-search-body.jpg)

    A sample **Assignments Search** operation payload is shown here:

```json
{
  "count": 4,
  "query": {
    "textQuery": {
      "fields": ["description"],
      "searchPhrase": "*"
    }
  },
  "start": 2
}
```

1.  Add the body you obtained in the previous step to the **Content** parameter.

2.  Click the plus sign (**+**) next to the **Connector configuration** field to configure B2C Data
    Connector with the required values:

    ![OAuth 2 Application Connection Provider authentication configuration example](/mulesoft/current/en-us/commerce-cloud-b2c-data-connector/latest/_images/data-api-connector-oauth2-configuration.jpg)

3.  Click **Test Connection**.

4.  Save the Mule project.

## Run the Mule Application

Run the project as a Mule application:

1.  In **Package Explorer**, right-click the project name and select **Run As > Mule Application**.

2.  Navigate to `http://localhost:8081/assignmentsSearch`, open Postman, and check the response.

You see the search data result in the output.

### XML Example

Paste this code into the **Configuration XML** tab in Studio to quickly load the flow for this
example into your Mule app:

```xml
<?xml version="1.0" encoding="UTF-8"?>

<mule xmlns:commerce-cloud-dataapi="http://www.mulesoft.org/schema/mule/commerce-cloud-dataapi" xmlns:http="http://www.mulesoft.org/schema/mule/http"
	xmlns="http://www.mulesoft.org/schema/mule/core"
	xmlns:doc="http://www.mulesoft.org/schema/mule/documentation" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.mulesoft.org/schema/mule/core http://www.mulesoft.org/schema/mule/core/current/mule.xsd
http://www.mulesoft.org/schema/mule/http http://www.mulesoft.org/schema/mule/http/current/mule-http.xsd
http://www.mulesoft.org/schema/mule/commerce-cloud-dataapi http://www.mulesoft.org/schema/mule/commerce-cloud-dataapi/current/mule-commerce-cloud-dataapi.xsd">
	<flow name="assignments-searchFlow" >
		<http:listener doc:name="8081/pricing/assignments/{version}/organizations/{organizationId}/assignments"  config-ref="HTTP_Listener_config" path="/pricing/assignments/{version}/organizations/{organizationId}/assignments"/>
		<commerce-cloud-dataapi:create-pricing-assignments-organizations-assignments-by-version-organization-id doc:name="Assignments Search"
    config-ref="Commerce_Cloud_Data_Connector_Config" version="#[attributes.uriParams.version]" organizationId="#[attributes.uriParams.organizationId]" siteId="#[attributes.queryParams.siteId]">
			<commerce-cloud-dataapi:content ><![CDATA[#[{
  "count": 4,
  "query": {
    "textQuery": {
      "fields": [
        "description"
      ],
      "searchPhrase": "*"
    }
  },
  "start": 2
}]]]></commerce-cloud-dataapi:content>
		</commerce-cloud-dataapi:create-pricing-assignments-organizations-assignments-by-version-organization-id>
	</flow>
</mule>
```

After adding the code in the Configuration XML tab, you can see the flow in the \*Message Flow\* tab
of the canvas.

## See Also

- [Salesforce Help](https://help.salesforce.com)

- [B2C Data Connector Reference](https://docs.mulesoft.com/commerce-cloud-b2c-data-connector/latest/commerce-cloud-b2c-data-connector-reference)
