Migrate to the MuleSoft HTTP Connector

The Salesforce B2C Commerce Data Connector and Salesforce B2C Commerce Shop Connector are deprecated and replaced with the MuleSoft HTTP Connector.

If you have existing Mule apps that currently use the Salesforce B2C Commerce Connectors, use the following steps as a blueprint to migrate to the MuleSoft HTTP Connector.

Salesforce B2C Commerce Data Connector - Mule 4

The Salesforce B2C Commerce Data Connector has two main elements. Both need to be migrated to the MuleSoft HTTP Connector request operation:

  • B2C Commerce Data Connector global configuration
  • Message flow containing the Salesforce B2C Commerce Data Connector operation

Migrate the B2C Commerce Data Connector Global Configuration

You must migrate the am-oauth2-configuration to the mule-oauth-module extension of the HTTP Connector.

For details, see Configure OAuth2 Client Credentials Grant Type Authentication.

  1. Make sure the HTTP Connector is a dependency in your project, for example:
<dependency>
    <groupId>org.mule.connectors</groupId>
    <artifactId>mule-http-connector</artifactId>
    <version>1.10.3</version>
    <classifier>mule-plugin</classifier>
</dependency>
  1. Add the mule-oauth-module extension to your project, for example:
<dependency>
    <groupId>org.mule.modules</groupId>
    <artifactId>mule-oauth-module</artifactId>
    <version>1.1.21</version>
    <classifier>mule-plugin</classifier>
</dependency>
  1. Create an HTTP Request configuration as a global configuration element. This is used in all flows.

    MuleSoft Data connector HTTP configuration settings

  2. For Authentication, select Client credentials grant type.

    MuleSoft Data connector global properties configuration for client credentials grant type

  3. Specify Protocol and Host properties.

    MuleSoft Data connector global properties configuration for protocol and host

  4. Configure the new http:request-config properties with the following values from your existing am-oauth2-config.

note: Make sure scopes contains the scope for your instance, for example: SALESFORCE_COMMERCE_API:bjms_dev.

http:request-config property name Value Copy from am-oauth2-config
host baseUri Yes
protocol HTTPS No, static value
clientId clientId Yes
clientSecret clientSecret Yes
scopes scopes Yes
tokenUrl tokenUrl Yes

The global HTTP Request Configuration with OAuth authentication is now fully configured.

XML Views Before and After Migration

Before migration:

<commerce-cloud-dataapi:am-oauth2-config
    name="Commerce_Cloud_B2C_Data_Connector_Am_oauth_2_config"
    doc:name="Commerce Cloud B2C Data Connector Am oauth 2 config"
    doc:id="11bc93bc-e1aa-4004-bae3-f8570173fdf2"
>
    <commerce-cloud-dataapi:am-oauth2-connection baseUri="<url>">
        <commerce-cloud-dataapi:oauth-client-credentials
            clientId="<clientID>"
            clientSecret="<clientSecret>"
            scopes="SALESFORCE_COMMERCE_API:bjms_dev sfcc.example sfcc.products.rw sfcc.products"
            tokenUrl="<tokenURL>"
       />
    </commerce-cloud-dataapi:am-oauth2-connection>
</commerce-cloud-dataapi:am-oauth2-config>

After migration:

<http:request-config name="HTTP_Request_configuration" >
    <http:request-connection host="<url>" protocol="HTTPS>
    <http:authentication>
        <oauth:client-credentials-grant-type
        clientId="<clientID>"
        clientSecret="<clientSecret>"
        tokenUrl="<tokenURL>"
        scopes="SALESFORCE_COMMERCE_API:bjms_dev sfcc.example sfcc.products.rw sfcc.products" />
    </http:authentication>
    </http:request-connection>
</http:request-config>

Migrate the Message Flow Containing the Salesforce B2C Commerce Data Connector Operation

All commerce-cloud-dataapi operations have an organizationId, config-ref, version_ property, and various additional properties corresponding to the operation, for example, get-product has a productId:

<flow name="DataConnectorMigrationFlow"
    doc:id="adf832b2-733e-4e18-8fb9-c35570c81083"
>
    <http:listener
        doc:name="Listener"
        doc:id="b381c6c5-b5c8-4f12-bed7-f0e0df1d6076"
        config-ref="HTTP_Listener_config"
        path="/test" />
    <commerce-cloud-dataapi:get-product-products-organizations-products-by-version-organization-id-product-id
        doc:name="Get Product"
        doc:id="6b1b33d9-86c8-458f-89fe-9b35272bd6fe"
        config-ref="Commerce_Cloud_B2C_Data_Connector_Config"
        version="v1"
        organizationId="f_ecom_bjms_dev"
        productId="apple-ipod-classic"
    />
</flow>

Migrate all flows in your application using the following steps:

  1. Copy your existing flow.
  2. In the copy of the flow, remove the commerce-cloud-dataapi operation.
  3. Add the http:request operation to the corresponding place in the flow.
  4. In the Mule Palette view, select HTTP > Request.
  5. Drag Request to the Studio canvas and the flow.
  6. Select the plus sign (+) next to the Connector configuration field to configure the previously created global HTTP Request Configuration with OAuth authentication, as shown in the following example. For details, see: Migrate to global configuration using mule-oauth-module extension.
<flow name="HTTPConnectorFlow"
    doc:id="23142ccf-73ed-4711-8ae0-322d8996d374"
>
    <http:listener
      doc:name="Listener"
      doc:id="ac5d6ce1-260e-4147-a0bb-8e1fa0d430ec"
      config-ref="HTTP_Listener_config"
      path="/test2"
   />
    <http:request
      method="GET"
      doc:name="Request"
      doc:id="8825fb47-cb94-4b9d-a2e6-5afd927389c1"
      config-ref="HTTP_Request_configuration"
      path="/product/products/v1/organizations/f_ecom_bjms_dev/products/apple-ipod-classic"/>
</flow>
  1. Configure the new http:request properties with the following values from your existing commerce-cloud-dataapi operation. You can get API details for your operation from SCAPI Reference documentation, for example: getProduct.

MuleSoft Data connector API flow configuration details

  1. Copy the method and path with placeholders from the applicable documentation, for example: /product/products/v1/organizations/{organizationId}/products/{productId}.

  2. Add URI parameter, query parameter, body, and header to the HTTP Connector request operation.

http:request property name Value
config-ref HTTP_Request_configuration See: Migrate to global configuration using mule-oauth-module extension for the previously created http:request-config property name.
method Copy operation from SCAPI documentation **** (GET) SCAPI documentation
path Copy path with placeholder from SCAPI documentation SCAPI documentation
base URI parameter {organizationId} commerce-cloud-dataapi : organizationId Copy from commerce-cloud-dataapi operation property organizationId.
additional URI parameter SCAPI documentation, if applicable
Query parameter SCAPI documentation, if applicable
Body SCAPI documentation, if applicable
Header SCAPI documentation, if applicable

For details, see the following documentation:

MuleSoft Data connector API parameter configuration details

  1. If required, add additional configuration according to HTTP Connector capabilities:

App Flow Before and After Migration

Commerce Data Connector HTTP Connector
<ul><li>Listener</li><li>Get Product (Commerce Data Connector operation)</li></ul> <ul><li>Listener</li><li>Get Product (HTTP Connector Request operation)</li></ul>
MuleSoft application flow diagram for Data API connector integration MuleSoft HTTP flow diagram for Data connector processing

XML Views Before and After Migration

Before migration:

<flow name="DataConnectorMigrationFlow"
    doc:id="adf832b2-733e-4e18-8fb9-c35570c81083"
>
    <http:listener
        doc:name="Listener"
        doc:id="b381c6c5-b5c8-4f12-bed7-f0e0df1d6076"
        config-ref="HTTP_Listener_config"
        path="/test" />
    <commerce-cloud-dataapi:get-product-products-organizations-products-by-version-organization-id-product-id
        doc:name="Get Product"
        doc:id="6b1b33d9-86c8-458f-89fe-9b35272bd6fe"
        config-ref="Commerce_Cloud_B2C_Data_Connector_Config"
        version="v1"
        organizationId="f_ecom_bjms_dev"
        productId="apple-ipod-classic"
    />
</flow>

After migration:

<flow name="HTTPConnectorFlow"
    doc:id="23142ccf-73ed-4711-8ae0-322d8996d374"
>
    <http:listener
        doc:name="Listener"
        doc:id="ac5d6ce1-260e-4147-a0bb-8e1fa0d430ec"
        config-ref="HTTP_Listener_config"
        path="/test" />

    <http:request
        method="GET"
        doc:name="Request"
        doc:id="8825fb47-cb94-4b9d-a2e6-5afd927389c1"
        config-ref="HTTP_Request_configuration"
        path="/product/products/v1/organizations/{organizationId}/products/{productId}"
    >
        <http:uri-params >
            <![CDATA[#[output application/java
            ---
            {
            "productId" : "apple-ipod-classic",
            "organizationId" : "f_ecom_bjms_dev"
            }]]]>
       </http:uri-params>
    </http:request>
</flow>

Salesforce B2C Commerce Shop Connector - Mule 4

You must migrate all elements of the Salesforce B2C Commerce Shop Connector to the MuleSoft HTTP Connector request operation.

note: The Salesforce B2C Commerce Shop Connector uses a deprecated auth call, which is no longer supported. For details, see B2C Commerce API Release Notes and Authorization for Shopper APIs.

Migrate the B2C Commerce Shop Connector Global Configuration

You must migrate the shopper-token-config objects shopper-token-connection and customer-auth-config to the HTTP Connector.

MuleSoft Shop connector general configuration settings

  1. Make sure the HTTP Connector is a dependency in your project, for example:
<dependency>
    <groupId>org.mule.connectors</groupId>
    <artifactId>mule-http-connector</artifactId>
    <version>1.10.3</version>
    <classifier>mule-plugin</classifier>
</dependency>
  1. Create an HTTP Request Configuration as a global configuration element to be used in all flows.

MuleSoft Shop connector HTTP configuration settings

note: Although the mule-oauth-module allows client-credentials-grant-type, the configuration does not allow additional parameters that SCAPI requires. Therefore, an additional HTTP Connector Configuration for OAuth is used. For details, see: https://docs.mulesoft.com/http-connector/1.5/http-authentication#oauth2cc.

  1. Configure the new http:request-config properties with the following values from your existing shopper-token-connection and customer-auth-config:
http:request-config property name Value Copy from shopper-token-connection and customer-auth-config?
host baseUri Yes
protocol HTTPS No, static value
clientId clientId Yes
clientSecret clientSecret Yes

MuleSoft Shop connector token configuration and authentication setup MuleSoft Shop connector authentication configuration interface

XML View

    <http:request-config
        name="HTTP_Request_Auth_configuration"
        doc:name="HTTP Request configuration"
        doc:id="5be8a127-4b2f-42f3-b1bf-d29b5f0611ac" >
        <http:request-connection
            protocol="HTTPS"
            host="sandbox-001.api.commercecloud.salesforce.com"
        >
            <http:authentication >
                <http:basic-authentication
                    # basic credentials from commerce-cloud-shopper-api:create-shopper-auth-organizations-oauth2-token-by-version-organization-id
                    username="<your username>"
                    password="<your password>" />
            </http:authentication>
        </http:request-connection>
    </http:request-config>

    <http:request-config
        name="HTTP_Request_configuration"
    >
        <http:request-connection
            host="sandbox-001.api.commercecloud.salesforce.com"
            protocol="HTTPS">
        </http:request-connection>
    </http:request-config>

Migrate B2C Commerce Shop Connector Message Flows

All commerce-cloud-shopper-api operations have an organizationId, config-ref, siteId, version_ property and various additional properties corresponding to the operation, for example: get-product has a productId.

Migrate these in a manner similar using the previous steps, for example:

<flow name="ShopConnectorMigrationFlow"
    doc:id="4dc8dc1d-7cd3-4423-9240-1ce3b4e95a0f"
>
    <http:listener
        doc:name="Listener"
        doc:id="ff006824-2ac9-494b-9403-9786fd285734"
        config-ref="HTTP_Listener_config"
        path="/test"
   />
   # Get access token for guest customer
    <commerce-cloud-shopper-api:create-shopper-auth-organizations-oauth2-token-by-version-organization-id
        doc:name="Get Access Token"
        doc:id="347fcaa3-639e-451a-ae7f-5f5c6ce49c35"
        config-ref="Commerce_Cloud_B2C_Shop_Connector_Shopper_token_config"
        version="v1"
        organizationId="f_ecom_bjms_dev"
        authorization="Basic <your basic credentials>"
    >
        <commerce-cloud-shopper-api:custom-query-params >
            <![CDATA[#[output application/java
                ---
                {
                    "grant_type" : "client_credentials",
                    "channel_id" : "SiteGenesis"
            }]]]>
        </commerce-cloud-shopper-api:custom-query-params>
        <commerce-cloud-shopper-api:custom-headers >
            <![CDATA[#[output application/java
                ---
                {
                "Content-Type" : "application/x-www-form-urlencoded"
            }]]]>
       </commerce-cloud-shopper-api:custom-headers>
    </commerce-cloud-shopper-api:create-shopper-auth-organizations-oauth2-token-by-version-organization-id>
    # set authorization access token to variable authorization
    <set-variable
        value='#[&quot;Bearer &quot; ++ payload.access_token]'
        doc:name="Set Authorization"
        doc:id="2afa706f-0569-4c37-a748-cdd5a6abdf60"
        variableName="authorization"
    />
    <commerce-cloud-shopper-api:get-product-shopper-products-organizations-products-by-version-organization-id-id
        doc:name="Get Product"
        doc:id="8cd547ef-1ffc-4719-961e-39a49109004a"
        version="v1"
        config-ref="Commerce_Cloud_B2C_Shop_Connector_Customer_auth_config"
        organizationId="f_ecom_bjms_dev"
        siteId="SiteGenesis"
        id="apple-ipod-classic"
    />
</flow>

For a registered shopper, there might be similar flow operation objects containing authorization and authentication, for example:

<commerce-cloud-shopper-api:create-shopper-auth-organizations-oauth2-login-by-version-organization-id
    doc:name="Authenticate Customer"
    doc:id="432892fb-c84b-44a6-8407-2df7dad561e3"
    config-ref="Commerce_Cloud_B2C_Shop_Connector_Shopper_token_config"
    version="${shopper.version}"
    organizationId="${shopper.orgId}"
    authorization="#[attributes.headers.Authorization]">
            <commerce-cloud-shopper-api:content >
                <![CDATA[#[%dw 2.0
                    output application/x-www-form-urlencoded
                    ---
                    {
                    "grant_type":"authorization_code_pkce",
                    "client_id":"3a15f34e-fecd-4fcc-8235-86b70978e629",
                    "redirect_uri":"http://localhost:9010/callback",
                    "code_challenge": attributes.queryParams.code_challenge,
                    "channel_id": "SiteGenesis"
                   }]]]>
            </commerce-cloud-shopper-api:content>
</commerce-cloud-shopper-api:create-shopper-auth-organizations-oauth2-login-by-version-organization-id>

App Flow Before and After Migration

Commerce Shop Connector HTTP Connector
<ul><li>Listener</li><li>Get Access token (for guest/unregistered customer) (Commerce Shop Connector operation)</li><li>Set variable for jwt-token</li><li>Logger (optional)</li><li>Get Product (Commerce Shop Connector operation)</li></ul> <ul><li>Listener</li><li>Get Access token (for guest/unregistered customer) (Commerce Shop Connector operation)</li><li>Set variable for jwt-token</li><li>Logger (optional)</li><li>Get Product (HTTP Connector request operation)</li></ul>
MuleSoft application flow diagram for Shop API connector integration MuleSoft HTTP flow diagram for Shop connector data processing

Migrate all flows in your application to a flow utilizing the HTTP Connector:

  1. Copy your existing flow.
  2. In the copy of the flow, remove the commerce-cloud-dataapi operation.
  3. Add the http:request operation to the corresponding place in the flow.
  4. In the Mule Palette view, select HTTP > Request.
  5. Drag Request to the Studio canvas and the flow.
  6. Click the plus sign (+) next to the Connector configuration field to configure the previously created global HTTP Request Configuration. For details, see: Global configuration containing the Shop_Connector_Customer_auth_config and Shop_Connector_Shopper_token_config.
  7. Configure the new http:request properties with the following values from your existing commerce-cloud-shopapi operation.

MuleSoft Shop connector global properties configuration MuleSoft Shop connector global properties configuration

  1. Get API details for your operation from the SCAPI documentation, for example:

MuleSoft Shop connector API flow configuration details

MuleSoft Shop connector API parameter configuration details

  1. Copy the method and path with placeholders from the applicable documentation, for example:
  • /shopper/auth/v1/organizations/{organizationId}/oauth2/token
  • /product/products/v1/organizations/{organizationId}/products/{productId}
  1. Add URI parameter, query parameter, body and header to the HTTP Connector request operation.

MuleSoft Shop connector API parameter configuration options

For Get Access token (HTTP Connector request operation)

http:request property name Value Notes
config-ref HTTP_Request_Auth_configuration See the previously created http:request-config property name, which contains the Basic credentials for Basic auth.
method Copy operation from SCAPI documentation (GET) SCAPI documentation
path Copy path with placeholder from SCAPI documentation SCAPI documentation
base URI parameter {organizationId} commerce-cloud-shopapi : organizationId Copy from commerce-cloud-shopapi operation property organizationId.
additional URI parameter SCAPI documentation, if applicable
Query parameter commerce-cloud-shopper-api:custom-query-params "grant_type" : "client_credentials", "channel_id" : "SiteGenesis" SCAPI documentation, if applicable
Body SCAPI documentation, if applicable
Header commerce-cloud-shopper-api:custom-headers "Content-Type":"application/x-www-form-urlencoded" SCAPI documentation, if applicable

For Get Product (HTTP Connector request operation)

http:request property name Value Notes
config-ref HTTP_Request_configuration See the previously created http:request-config property name.
method Copy operation from SCAPI documentation (GET) SCAPI documentation
path Copy path with placeholder from SCAPI documentation SCAPI documentation
base URI parameter {organizationId} commerce-cloud-shopapi : organizationId Copy from commerce-cloud-shopapi operation property organizationId.
additional URI parameter commerce-cloud-shopper-api:get-product-shopper-products-organizations-products-by-version-organization-id-id → id SCAPI documentation, if applicable
Query parameter commerce-cloud-shopper-api:get-product-shopper-products-organizations-products-by-version-organization-id-id → siteId SCAPI documentation, if applicable
Body SCAPI documentation, if applicable
Header SCAPI documentation, if applicable

For additional details, see the following documentation:

  1. If required, add additional configuration according to HTTP Connector capabilities. For details, see the following documentation:

XML Views Before and After Migration

Before migration:

<flow name="ShopConnectorMigrationFlow"
    doc:id="4dc8dc1d-7cd3-4423-9240-1ce3b4e95a0f"
>
    <http:listener
        doc:name="Listener"
        doc:id="ff006824-2ac9-494b-9403-9786fd285734"
        config-ref="HTTP_Listener_config"
        path="/test"
   />
   # Get jwt-token for guest customer
    <commerce-cloud-shopper-api:create-shopper-auth-organizations-oauth2-token-by-version-organization-id
        doc:name="Get Access Token"
        doc:id="347fcaa3-639e-451a-ae7f-5f5c6ce49c35"
        config-ref="Commerce_Cloud_B2C_Shop_Connector_Shopper_token_config"
        version="v1"
        organizationId="f_ecom_bjms_dev"
        authorization="Basic <your basic credentials>"
    >
        <commerce-cloud-shopper-api:custom-query-params >
            <![CDATA[#[output application/java
                ---
                {
                    "grant_type" : "client_credentials",
                    "channel_id" : "SiteGenesis"
            }]]]>
        </commerce-cloud-shopper-api:custom-query-params>
        <commerce-cloud-shopper-api:custom-headers >
            <![CDATA[#[output application/java
                ---
                {
                "Content-Type" : "application/x-www-form-urlencoded"
            }]]]>
       </commerce-cloud-shopper-api:custom-headers>
    </commerce-cloud-shopper-api:create-shopper-auth-organizations-oauth2-token-by-version-organization-id>

    # set authorization access token to variable authorization
    <set-variable
        value='#[&quot;Bearer &quot; ++ payload.access_token]'
        doc:name="Set Authorization"
        doc:id="2afa706f-0569-4c37-a748-cdd5a6abdf60"
        variableName="authorization"
    />
    # commerce-cloud-shopper-api:shopper-connection
    # configuration parameter > authorization
    <commerce-cloud-shopper-api:get-product-shopper-products-organizations-products-by-version-organization-id-id
        doc:name="Get Product"
        doc:id="8cd547ef-1ffc-4719-961e-39a49109004a"
        version="v1"
        config-ref="Commerce_Cloud_B2C_Shop_Connector_Customer_auth_config"
        organizationId="f_ecom_bjms_dev"
        siteId="SiteGenesis"
        id="apple-ipod-classic"
    />
</flow>

After migration:

<flow name="HTTPConnectorFlow"
    doc:id="aba98309-f8c4-43fd-bf2e-7936738057c6"
>
    <http:listener
        doc:name="Listener"
        doc:id="df9c1b70-ee7e-4497-9504-a2db7dbfedf6"
        config-ref="HTTP_Listener_config"
        path="/test"
   />
   # get jwt-token for guest customer
    <http:request
        method="POST"
        doc:name="Get Access token"
        doc:id="49cc1ca2-4900-4c42-b704-7f0a98923229"
        # http config with basic credentials
        config-ref="HTTP_Request_Auth_configuration"
        path="/shopper/auth/v1/organizations/{organizationId}/oauth2/token">
        <http:headers >
            <![CDATA[#[output application/java
                ---
                {
                    "Content-type" : "application/x-www-form-urlencoded"
                }
            ]]]>
        </http:headers>
        <http:uri-params >
            <![CDATA[#[output application/java
                ---
                {
                    "organizationId" : "f_ecom_bjms_dev"
                }
            ]]]>
        </http:uri-params>
        <http:query-params >
            <![CDATA[#[output application/java
                ---
                {
                    "grant_type" : "client_credentials",
                    "channel_id" : "SiteGenesis"
                }
            ]]]>
        </http:query-params>
    </http:request>
   # set authorization access token to variable authorization
    <set-variable
        value='#["Bearer " ++ payload.access_token]'
        doc:name="Set Authorization"
        doc:id="ab79d83f-4726-4b52-b3eb-8fb23b936a16"
        variableName="authorization"
    />


    <http:request
        method="GET"
        doc:name="Request Get Product"
        doc:id="d6f30c66-0767-4d90-9553-3edd692667e6"
        config-ref="HTTP_Request_configuration"
        path="/product/shopper-products/v1/organizations/{organizationId}/products/{productId}" >
        <http:headers >
            <![CDATA[#[output application/java
                ---
                {
                "Authorization" : "$(vars.authorization)",
                "Content-type" : "application/json"
                }]]]>
       </http:headers>
        <http:uri-params >
            <![CDATA[#[output application/java
                ---
                {
                "organizationId" : "f_ecom_bjms_dev",
                "productId" : "apple-ipod-classic"
                }]]]>
       </http:uri-params>
        <http:query-params >
            <![CDATA[#[output application/java
                ---
                {
                "siteId" : "SiteGenesis"
                }]]]>
            </http:query-params>
    </http:request>
</flow>