Work with Custom Actions

The standard REST API architecture focuses on the basic create, read, update and delete (CRUD) methods. In complex applications, there's often a need to run processes that can't be achieved using the CRUD methods. In such cases, custom actions are used. The custom actions use target URLs containing the "custom-actions" path element. Not all actions will require a request body or payload.

ADF supports custom action URLs with and without the action name. The URLs are autogenerated from the resource. The resource and the API version determine if the URL should contain the custom action or not. The request payload would vary depending on whether the URL contains the custom action or not.

Let's for example take the custom action 'close' and consider different scenarios with examples of the payload to understand how the request needs to be structured.

Scenario 1

If a request URL contains a custom action name, the payload need not repeat the action name.

Request URL

curl -u username:password -X POST -H "Content-Type:application/vnd.oracle.adf.action+json" -d 'request payload' "https://servername/fscmRestApi/resources/version/<resourceName>/{resourceNameID}/action/close"

Request payload

{
    "closeAction": "close",
    "closeReason": "Header close reason"
}

Scenario 2

If a request URL doesn't contain a custom action name, the payload must contain the action name.

Request URL

curl -u username:password -X POST -H "Content-Type:application/vnd.oracle.adf.action+json" -d 'request payload' "https://servername/fscmRestApi/resources/version/<resourceName>/{resourceNameID}"

Request payload

{
    "name": "close",
    "parameters": [
    {
        "closeAction": "close"
    },
    {
        "closeReason": "Header close reason"
    }
    ]
}

Note:

  • Make sure you structure the request payload as per the URL and preferably use the custom action URLs with the action name.
  • Don't use request payload with action name when the URL contains the action name and don't use URL without action name when the payload doesn't contain the action name.