Run a User-Defined Query Asynchronously

Use an asynchronous request to run a user-defined query as an extract job. Use this request when you need to provide parameter values at runtime. The request returns after submitting the job, allowing you to monitor the job and retrieve its output later.

  1. Identify the user-defined query that you want to run.

  2. If the query includes parameters, obtain the required parameter names and values.

  3. Determine whether to send a callback and select the required output format.

    Set CallbackFlag to Y only when you want the configured callback workflow agent to receive extract completion details. Configure the callback workflow agent before you send the request. For more information, see Configure a Callback Workflow Agent.

    Valid values for OutputFormat are CSV and JSON. The default value is CSV.

  4. Submit a POST request to the runExtract endpoint.

    POST /fscmRestApi/scm/redwood/11.13.18.05/runExtract

Request Example

{
  "UserDefinedQueryName": "PendingInvoice",
  "Type": "ORA_ASYNC",
  "CallbackFlag": "Y",
  "OutputFormat": "JSON",
  "Parameters": {
    "pOrgCode": "M1",
    "pWoNumber": "M1-1100"
  }
}

Response Example

{
  "Type": "ORA_ASYNC",
  "ExecutionId": "300100679918132",
  "ExtractDefinitionName": null,
  "UserDefinedQueryName": "PendingInvoice",
  "CallbackFlag": "Y",
  "OutputFormat": "JSON",
  "Parameters": {
    "pOrgCode": "M1",
    "pWoNumber": "M1-1100"
  },
  "RequestId": "92747",
  "Status": "Success",
  "Result": null
}

The response includes a RequestId after the extract job is submitted successfully. Use the request ID to monitor the job and retrieve the extract output. For more information, see Monitor Extract Activity.

Note: For this request pattern, don’t send ExtractDefinitionName. The API ignores this attribute.