OCAPI & Jobs

Set up OCAPI for a connection, activate code versions and run jobs from the B2C OCAPI tool window

OCAPI is optional in Intellij SFCC. Turn it on for a connection to activate code versions from B2C Explorer and to run jobs from the B2C OCAPI tool window at the bottom of the IDE. Uploads, deploys, B2C Explorer and the debugger don't need it, they use the connection's account

Set up OCAPI

Add an API client

On the OCAPI tab of B2C Credentials, add your API client with its client ID and secret. On sandboxes and test systems you can start with the built-in OOTB Test Creds client

Allow the client on the instance

Grant the client the Data API resources below in Business Manager, see Business Manager setup

Turn it on for the connection

In Connections Settings, open the OCAPI tab, check Use OCAPI, pick the Credentials and the Version, then click Test OCAPI Connection

Business Manager setup

  1. In Business Manager, go to Administration › Site Development › Open Commerce API Settings
  2. Select Data API and Global
  3. Add a client entry like the one below, with your client ID and an OCAPI version your instance supports, then save
Data API › Global
{
    "_v": "23.2",
    "clients": [
        {
            "client_id": "<your-client-id>",
            "resources": [
                {
                    "resource_id": "/code_versions/*",
                    "methods": ["patch"],
                    "read_attributes": "(**)",
                    "write_attributes": "(**)"
                },
                {
                    "resource_id": "/jobs/*/executions",
                    "methods": ["post"],
                    "read_attributes": "(**)",
                    "write_attributes": "(**)"
                },
                {
                    "resource_id": "/jobs/*/executions/*",
                    "methods": ["get"],
                    "read_attributes": "(**)",
                    "write_attributes": "(**)"
                }
            ]
        }
    ]
}

These are the three calls the plugin makes: activate a code version, start a job execution and read its status. If the settings already list other clients, add your entry to the existing clients array instead of replacing it

No WebDAV client permissions needed

Guides for command line tools often add WebDAV Client Permissions for the API client too. Intellij SFCC doesn't need them, because its WebDAV requests use the connection's account (password or WebDAV access key), not the API client

Obtain a Business Manager user grant on the connection's OCAPI tab requests the token from the instance itself instead of Account Manager. Leave it off unless your setup needs that grant

Activate a code version

With OCAPI on, right-click a version under Code versions in B2C Explorer

ItemWhat it does
Activate and Select Code VersionActivates the version on the instance and selects it for uploads and deploys
Activate Code VersionActivates the version on the instance only
Select Code VersionSelects it for uploads and deploys without activating it. This one works without OCAPI

The activated version is marked "[Active on instance]" in the tree and in the toolbar code version list. More on code versions in Deploy Code

B2C OCAPI tool window

The window has one tab per instance. With no tab yet it shows "No OCAPI Configurations"

  1. Click + (New OCAPI Connection), choose the Instance and click Create. Pick a connection, groups can't be used
  2. The tab toolbar shows the connection's settings and lets you change them in place
ToolbarWhat it does
Use OCAPI:Turns OCAPI on or off for the connection, same as Use OCAPI in Connections Settings
Instance:The connection the tab works with, plus Edit Connection to open its settings
Credentials:The API client used for requests
Version:The OCAPI version used for requests

Closing a tab asks before it removes that OCAPI connection from the window

Run jobs

The Jobs tab lists job IDs with their status. Add them by hand or find them in your code

ActionWhat it does
Find Jobs in jobs.xmlAdds every job-id found in the project's jobs.xml files
Add JobAdds one job by ID ("Enter Job ID")
Run JobStarts the selected jobs. With several selected it reads "Run 3 Jobs"
Remove JobRemoves the selected jobs from the list after a confirmation. The jobs on the instance are not touched

A running job shows "(Running)" after its ID, and its Status is refreshed every 2 seconds until it ends, for example with OK or ERROR. A job that is still pending or running can't be started again. Right-click a row to run or remove it

Find Jobs in jobs.xml adds the job IDs from the project's jobs.xml files to the Jobs tab. Run Job starts the selected jobs over OCAPI, and the Status column follows each run from PENDING and RUNNING to OK or ERROR

Troubleshooting

MessageWhat to do
OCAPI Not EnabledTurn on Use OCAPI for the connection, then try again
"OCAPI is not configured for" the instanceEnable OCAPI, select the credentials and the version, and validate the connection
OCAPI Auth FailedThe client ID or secret is wrong, or the client is not allowed on this instance
OCAPI Error with a message from the serverUsually missing permissions. The balloon's Edit Data API opens the Business Manager page from Business Manager setup
Running Job ErrorThe job ID doesn't exist on the instance, or the client can't run jobs
Run Job is disabledOCAPI is off for the tab, nothing is selected, or the selected job is still running

On this page