Call the DFS Named Credential

Quick example of how to call the DFS named credential as an Apex callout.

User Permissions Needed
To use the Developer Console: API Enabled AND View All Data
To view, retain, and delete debug logs: View All Data
To execute anonymous Apex: Author Apex
To use code search and run SOQL or SOSL on the query tab: API Enabled
To save changes to Apex classes and triggers: Author Apex
To save changes to Visualforce pages and components: Customize Application
To save changes to Lightning resources: Customize Application
For this task to be successful:
  • Both the org where you issue the query and the org or cloud that you want to query are connected to Customer 360 Data Manager as data sources.
  • You have accepted the default mappings for both data sources or mapped the same entities and attributes as the default mappings.
  • You have configured both the DFS External Data Source and the DFS Named Credential.
  • You have connected a Commerce Cloud instance as a data source that has a working site with order data.

    Replace SiteGenesis in the example with the name of your site.

    Note

This is a simple way to get started with the DFS named credential, if you want a quick way to try out the API and haven’t developed with named credentials before.

  1. Click the quick access menu (Setup gear icon).
  2. Click Developer Console.
  3. Click Debug.
  4. Click Open Execute Anonymous Window.
  5. Check Open Log.
  6. Enter the following code and click Execute.
    1Http http = new Http();
    2HttpRequest request = new HttpRequest();
    3String queryTest = 'SalesOrder?$filter=OrderNumber%20eq%20%27SiteGenesis__00000202%27&$select=GrandTotalAmount,OrderNumber';
    4request.setEndpoint('callout:DFS/'+queryTest);
    5request.setMethod('GET');
    6HttpResponse response = http.send(request);
    7System.debug(response.getBody());
    You can see what this returns in the log.