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:
1<dependency>
2    <groupId>org.mule.connectors</groupId>
3    <artifactId>mule-http-connector</artifactId>
4    <version>1.10.3</version>
5    <classifier>mule-plugin</classifier>
6</dependency>
  1. Add the mule-oauth-module extension to your project, for example:
1<dependency>
2    <groupId>org.mule.modules</groupId>
3    <artifactId>mule-oauth-module</artifactId>
4    <version>1.1.21</version>
5    <classifier>mule-plugin</classifier>
6</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.

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

Note

http:request-config property nameValueCopy from am-oauth2-config
hostbaseUriYes
protocolHTTPSNo, static value
clientIdclientIdYes
clientSecretclientSecretYes
scopesscopesYes
tokenUrltokenUrlYes

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

XML Views Before and After Migration 

Before migration:

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

After migration:

1<http:request-config name="HTTP_Request_configuration" >
2    <http:request-connection host="<url>" protocol="HTTPS>
3    <http:authentication>
4        <oauth:client-credentials-grant-type
5        clientId="<clientID>"
6        clientSecret="<clientSecret>"
7        tokenUrl="<tokenURL>"
8        scopes="SALESFORCE_COMMERCE_API:bjms_dev sfcc.example sfcc.products.rw sfcc.products" />
9    </http:authentication>
10    </http:request-connection>
11</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:

1<flow name="DataConnectorMigrationFlow"
2    doc:id="adf832b2-733e-4e18-8fb9-c35570c81083"
3>
4    <http:listener
5        doc:name="Listener"
6        doc:id="b381c6c5-b5c8-4f12-bed7-f0e0df1d6076"
7        config-ref="HTTP_Listener_config"
8        path="/test" />
9    <commerce-cloud-dataapi:get-product-products-organizations-products-by-version-organization-id-product-id
10        doc:name="Get Product"
11        doc:id="6b1b33d9-86c8-458f-89fe-9b35272bd6fe"
12        config-ref="Commerce_Cloud_B2C_Data_Connector_Config"
13        version="v1"
14        organizationId="f_ecom_bjms_dev"
15        productId="apple-ipod-classic"
16    />
17</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.
1<flow name="HTTPConnectorFlow"
2    doc:id="23142ccf-73ed-4711-8ae0-322d8996d374"
3>
4    <http:listener
5      doc:name="Listener"
6      doc:id="ac5d6ce1-260e-4147-a0bb-8e1fa0d430ec"
7      config-ref="HTTP_Listener_config"
8      path="/test2"
9   />
10    <http:request
11      method="GET"
12      doc:name="Request"
13      doc:id="8825fb47-cb94-4b9d-a2e6-5afd927389c1"
14      config-ref="HTTP_Request_configuration"
15      path="/product/products/v1/organizations/f_ecom_bjms_dev/products/apple-ipod-classic"/>
16</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 nameValue
config-refHTTP_Request_configurationSee: Migrate to global configuration using mule-oauth-module extension for the previously created http:request-config property name.
methodCopy operation from SCAPI documentation **** (GET)SCAPI documentation
pathCopy path with placeholder from SCAPI documentationSCAPI documentation
base URI parameter {organizationId}commerce-cloud-dataapi : organizationIdCopy from commerce-cloud-dataapi operation property organizationId.
additional URI parameterSCAPI documentation, if applicable
Query parameterSCAPI documentation, if applicable
BodySCAPI documentation, if applicable
HeaderSCAPI 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 ConnectorHTTP Connector
  • Listener
  • Get Product (Commerce Data Connector operation)
  • Listener
  • Get Product (HTTP Connector Request operation)
MuleSoft application flow diagram for Data API connector integrationMuleSoft HTTP flow diagram for Data connector processing

XML Views Before and After Migration 

Before migration:

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

After migration:

1<flow name="HTTPConnectorFlow"
2    doc:id="23142ccf-73ed-4711-8ae0-322d8996d374"
3>
4    <http:listener
5        doc:name="Listener"
6        doc:id="ac5d6ce1-260e-4147-a0bb-8e1fa0d430ec"
7        config-ref="HTTP_Listener_config"
8        path="/test" />
9
10    <http:request
11        method="GET"
12        doc:name="Request"
13        doc:id="8825fb47-cb94-4b9d-a2e6-5afd927389c1"
14        config-ref="HTTP_Request_configuration"
15        path="/product/products/v1/organizations/{organizationId}/products/{productId}"
16    >
17        <http:uri-params >
18            <![CDATA[#[output application/java
19            ---
20            {
21            "productId" : "apple-ipod-classic",
22            "organizationId" : "f_ecom_bjms_dev"
23            }]]]>
24       </http:uri-params>
25    </http:request>
26</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.

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.

Note

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:
1<dependency>
2    <groupId>org.mule.connectors</groupId>
3    <artifactId>mule-http-connector</artifactId>
4    <version>1.10.3</version>
5    <classifier>mule-plugin</classifier>
6</dependency>
  1. Create an HTTP Request Configuration as a global configuration element to be used in all flows.

MuleSoft Shop connector HTTP configuration settings

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.

Note

  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 nameValueCopy from shopper-token-connection and customer-auth-config?
hostbaseUriYes
protocolHTTPSNo, static value
clientIdclientIdYes
clientSecretclientSecretYes

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

XML View 

1<http:request-config
2        name="HTTP_Request_Auth_configuration"
3        doc:name="HTTP Request configuration"
4        doc:id="5be8a127-4b2f-42f3-b1bf-d29b5f0611ac" >
5        <http:request-connection
6            protocol="HTTPS"
7            host="sandbox-001.api.commercecloud.salesforce.com"
8        >
9            <http:authentication >
10                <http:basic-authentication
11                    # basic credentials from commerce-cloud-shopper-api:create-shopper-auth-organizations-oauth2-token-by-version-organization-id
12                    username="<your username>"
13                    password="<your password>" />
14            </http:authentication>
15        </http:request-connection>
16    </http:request-config>
17
18    <http:request-config
19        name="HTTP_Request_configuration"
20    >
21        <http:request-connection
22            host="sandbox-001.api.commercecloud.salesforce.com"
23            protocol="HTTPS">
24        </http:request-connection>
25    </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:

1<flow name="ShopConnectorMigrationFlow"
2    doc:id="4dc8dc1d-7cd3-4423-9240-1ce3b4e95a0f"
3>
4    <http:listener
5        doc:name="Listener"
6        doc:id="ff006824-2ac9-494b-9403-9786fd285734"
7        config-ref="HTTP_Listener_config"
8        path="/test"
9   />
10   # Get access token for guest customer
11    <commerce-cloud-shopper-api:create-shopper-auth-organizations-oauth2-token-by-version-organization-id
12        doc:name="Get Access Token"
13        doc:id="347fcaa3-639e-451a-ae7f-5f5c6ce49c35"
14        config-ref="Commerce_Cloud_B2C_Shop_Connector_Shopper_token_config"
15        version="v1"
16        organizationId="f_ecom_bjms_dev"
17        authorization="Basic <your basic credentials>"
18    >
19        <commerce-cloud-shopper-api:custom-query-params >
20            <![CDATA[#[output application/java
21                ---
22                {
23                    "grant_type" : "client_credentials",
24                    "channel_id" : "SiteGenesis"
25            }]]]>
26        </commerce-cloud-shopper-api:custom-query-params>
27        <commerce-cloud-shopper-api:custom-headers >
28            <![CDATA[#[output application/java
29                ---
30                {
31                "Content-Type" : "application/x-www-form-urlencoded"
32            }]]]>
33       </commerce-cloud-shopper-api:custom-headers>
34    </commerce-cloud-shopper-api:create-shopper-auth-organizations-oauth2-token-by-version-organization-id>
35    # set authorization access token to variable authorization
36    <set-variable
37        value='#[&quot;Bearer &quot; ++ payload.access_token]'
38        doc:name="Set Authorization"
39        doc:id="2afa706f-0569-4c37-a748-cdd5a6abdf60"
40        variableName="authorization"
41    />
42    <commerce-cloud-shopper-api:get-product-shopper-products-organizations-products-by-version-organization-id-id
43        doc:name="Get Product"
44        doc:id="8cd547ef-1ffc-4719-961e-39a49109004a"
45        version="v1"
46        config-ref="Commerce_Cloud_B2C_Shop_Connector_Customer_auth_config"
47        organizationId="f_ecom_bjms_dev"
48        siteId="SiteGenesis"
49        id="apple-ipod-classic"
50    />
51</flow>

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

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

App Flow Before and After Migration 

Commerce Shop ConnectorHTTP Connector
  • Listener
  • Get Access token (for guest/unregistered customer) (Commerce Shop Connector operation)
  • Set variable for jwt-token
  • Logger (optional)
  • Get Product (Commerce Shop Connector operation)
  • Listener
  • Get Access token (for guest/unregistered customer) (Commerce Shop Connector operation)
  • Set variable for jwt-token
  • Logger (optional)
  • Get Product (HTTP Connector request operation)
MuleSoft application flow diagram for Shop API connector integrationMuleSoft 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 nameValueNotes
config-refHTTP_Request_Auth_configurationSee the previously created http:request-config property name, which contains the Basic credentials for Basic auth.
methodCopy operation from SCAPI documentation (GET)SCAPI documentation
pathCopy path with placeholder from SCAPI documentationSCAPI documentation
base URI parameter {organizationId}commerce-cloud-shopapi : organizationIdCopy from commerce-cloud-shopapi operation property organizationId.
additional URI parameterSCAPI documentation, if applicable
Query parametercommerce-cloud-shopper-api:custom-query-params "grant_type" : "client_credentials", "channel_id" : "SiteGenesis"SCAPI documentation, if applicable
BodySCAPI documentation, if applicable
Headercommerce-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 nameValueNotes
config-refHTTP_Request_configurationSee the previously created http:request-config property name.
methodCopy operation from SCAPI documentation (GET)SCAPI documentation
pathCopy path with placeholder from SCAPI documentationSCAPI documentation
base URI parameter {organizationId}commerce-cloud-shopapi : organizationIdCopy from commerce-cloud-shopapi operation property organizationId.
additional URI parametercommerce-cloud-shopper-api:get-product-shopper-products-organizations-products-by-version-organization-id-id → idSCAPI documentation, if applicable
Query parametercommerce-cloud-shopper-api:get-product-shopper-products-organizations-products-by-version-organization-id-id → siteIdSCAPI documentation, if applicable
BodySCAPI documentation, if applicable
HeaderSCAPI 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:

1<flow name="ShopConnectorMigrationFlow"
2    doc:id="4dc8dc1d-7cd3-4423-9240-1ce3b4e95a0f"
3>
4    <http:listener
5        doc:name="Listener"
6        doc:id="ff006824-2ac9-494b-9403-9786fd285734"
7        config-ref="HTTP_Listener_config"
8        path="/test"
9   />
10   # Get jwt-token for guest customer
11    <commerce-cloud-shopper-api:create-shopper-auth-organizations-oauth2-token-by-version-organization-id
12        doc:name="Get Access Token"
13        doc:id="347fcaa3-639e-451a-ae7f-5f5c6ce49c35"
14        config-ref="Commerce_Cloud_B2C_Shop_Connector_Shopper_token_config"
15        version="v1"
16        organizationId="f_ecom_bjms_dev"
17        authorization="Basic <your basic credentials>"
18    >
19        <commerce-cloud-shopper-api:custom-query-params >
20            <![CDATA[#[output application/java
21                ---
22                {
23                    "grant_type" : "client_credentials",
24                    "channel_id" : "SiteGenesis"
25            }]]]>
26        </commerce-cloud-shopper-api:custom-query-params>
27        <commerce-cloud-shopper-api:custom-headers >
28            <![CDATA[#[output application/java
29                ---
30                {
31                "Content-Type" : "application/x-www-form-urlencoded"
32            }]]]>
33       </commerce-cloud-shopper-api:custom-headers>
34    </commerce-cloud-shopper-api:create-shopper-auth-organizations-oauth2-token-by-version-organization-id>
35
36    # set authorization access token to variable authorization
37    <set-variable
38        value='#[&quot;Bearer &quot; ++ payload.access_token]'
39        doc:name="Set Authorization"
40        doc:id="2afa706f-0569-4c37-a748-cdd5a6abdf60"
41        variableName="authorization"
42    />
43    # commerce-cloud-shopper-api:shopper-connection
44    # configuration parameter > authorization
45    <commerce-cloud-shopper-api:get-product-shopper-products-organizations-products-by-version-organization-id-id
46        doc:name="Get Product"
47        doc:id="8cd547ef-1ffc-4719-961e-39a49109004a"
48        version="v1"
49        config-ref="Commerce_Cloud_B2C_Shop_Connector_Customer_auth_config"
50        organizationId="f_ecom_bjms_dev"
51        siteId="SiteGenesis"
52        id="apple-ipod-classic"
53    />
54</flow>

After migration:

1<flow name="HTTPConnectorFlow"
2    doc:id="aba98309-f8c4-43fd-bf2e-7936738057c6"
3>
4    <http:listener
5        doc:name="Listener"
6        doc:id="df9c1b70-ee7e-4497-9504-a2db7dbfedf6"
7        config-ref="HTTP_Listener_config"
8        path="/test"
9   />
10   # get jwt-token for guest customer
11    <http:request
12        method="POST"
13        doc:name="Get Access token"
14        doc:id="49cc1ca2-4900-4c42-b704-7f0a98923229"
15        # http config with basic credentials
16        config-ref="HTTP_Request_Auth_configuration"
17        path="/shopper/auth/v1/organizations/{organizationId}/oauth2/token">
18        <http:headers >
19            <![CDATA[#[output application/java
20                ---
21                {
22                    "Content-type" : "application/x-www-form-urlencoded"
23                }
24            ]]]>
25        </http:headers>
26        <http:uri-params >
27            <![CDATA[#[output application/java
28                ---
29                {
30                    "organizationId" : "f_ecom_bjms_dev"
31                }
32            ]]]>
33        </http:uri-params>
34        <http:query-params >
35            <![CDATA[#[output application/java
36                ---
37                {
38                    "grant_type" : "client_credentials",
39                    "channel_id" : "SiteGenesis"
40                }
41            ]]]>
42        </http:query-params>
43    </http:request>
44   # set authorization access token to variable authorization
45    <set-variable
46        value='#["Bearer " ++ payload.access_token]'
47        doc:name="Set Authorization"
48        doc:id="ab79d83f-4726-4b52-b3eb-8fb23b936a16"
49        variableName="authorization"
50    />
51
52
53    <http:request
54        method="GET"
55        doc:name="Request Get Product"
56        doc:id="d6f30c66-0767-4d90-9553-3edd692667e6"
57        config-ref="HTTP_Request_configuration"
58        path="/product/shopper-products/v1/organizations/{organizationId}/products/{productId}" >
59        <http:headers >
60            <![CDATA[#[output application/java
61                ---
62                {
63                "Authorization" : "$(vars.authorization)",
64                "Content-type" : "application/json"
65                }]]]>
66       </http:headers>
67        <http:uri-params >
68            <![CDATA[#[output application/java
69                ---
70                {
71                "organizationId" : "f_ecom_bjms_dev",
72                "productId" : "apple-ipod-classic"
73                }]]]>
74       </http:uri-params>
75        <http:query-params >
76            <![CDATA[#[output application/java
77                ---
78                {
79                "siteId" : "SiteGenesis"
80                }]]]>
81            </http:query-params>
82    </http:request>
83</flow>