Retrieving failed events

You can retrieve the failed events that are not published to the configured endpoints by using REST API endpoints.

When the application cannot publish events to the configured endpoints like IBM Cloud® Object Storage or webhooks, you can download the failed events by using REST API. These events are available for three days post which they are purged.

There are three REST API endpoints that are available for retrieving the failed events.

To retrieve the failed events, you can implement a process to extract data from the endpoints periodically to monitor the failed events. You can extract the data as required to ensure that you do not miss any failed events.

Fetching failed events

Remember:
  • If you do not have the endpoint IDs, open a ticket with IBM® Support and request the endpoint IDs. To open a ticket, see IBM Support.

Procedure

  1. Call one of the following APIs to get the first 100 event files.
    • To get event files regardless of endpoint:
      curl --request GET \
      --url https://api.watsoncommerce.ibm.com/odx/{tenantId}/v1/failed-event-files \
      --header 'authorization: Bearer <bearer token>' \
      --header 'content-type: application/json'
    • To get event files from a particular endpoint:
      curl --request GET \
      --url https://api.watsoncommerce.ibm.com/odx/{tenantId}/v1/failed-event-files/endpoints/<endpoint ID> \
      --header 'authorization: Bearer <bearer token>' \
      --header 'content-type: application/json'
      To get event files for a particular event code:
      curl --request GET \
      --url https://api.watsoncommerce.ibm.com/odx/{tenantId}/v1/failed-event-files/events/<event code> \
      --header 'authorization: Bearer <bearer token>' \
      --header 'content-type: application/json'
      Note:
      • The legacy events and demandChange use a different event id as compared to the event code. This API understands event code (for example, supplyChange) and not the event id (for example, Supply.Change).
        For the new events, the event ids and event codes are the same.
      • If you have one endpoint that is receiving two or more event codes, this API retrieves all of the files for that endpoint.
      Sample output data:
      [
        {
           "endpointId": " eb188627-4556-410b-84a7-7b1b47da204e",
           "fileName": " eb188627-4556-410b-84a7-7b1b47da204e_2022-01-25T183415Z_96alBB1.zip",
           "downloadFileUrl": "https://s3.us-east.cloud-object-storage.appdomain.cloud/<failed event one time URL>",
           "urlExpiryInSeconds": "43200",
           "creationTimestamp": "Tue Jan 25 18:34:16 UTC 2022"
        }
        {
           "endpointId": " eb188627-4556-410b-84a7-7b1b47da204e",
           "fileName": " eb188627-4556-410b-84a7-7b1b47da204e_2022-01-25T183415Z_96alBB1.zip",
           "downloadFileUrl": "https://s3.us-east.cloud-object-storage.appdomain.cloud/<failed event one time URL>",
           "urlExpiryInSeconds": "43200",
           "creationTimestamp": "Tue Jan 25 18:34:16 UTC 2022"
        }
      ]
      Note: An empty array indicates that there are no files currently available to download. This call returns one of the first 100 event files in the pull queue for an endpoint. The new events are returned after the earlier events are deleted.
  2. Get each event file that was returned in the previous step and download the event file locally.
    curl <downloadFileUrl> --output <filename>
  3. After the file is saved, delete the event files on the endpoint.
    curl --request DELETE \
    --url https://api.watsoncommerce.ibm.com/odx/{tenantId}/v1/failed-event-files \
    --header 'authorization: Bearer <bearer token>' \
    --header 'content-type: application/json' \
    --data-raw '["filename1","filename2"]'
  4. Repeat the steps until all the messages are downloaded.
Note: The {tenantId} is the Sterling Intelligent Promising tenant ID and the {endpointId} is the id provided at the time of onboarding.