Exporting Deleted Records via APIs

Starting export of deleted MARC bib records

MARC Bib record is considered deleted if its LDR05 is set to “d”. The export of deleted MARC bib records can be triggered only via API call. The export job can be monitored via API calls or directly in the Data export app.

To start the export send POST request to {{url}}/data-export/export-deleted endpoint with valid folioAccessToken and Content-type set to application/json. The body of the request will contain the dates when the records were deleted records. The time of the deletion is determined by the value of 005 field, first eight values. Here is an example of the request body for export of records deleted on May 15, 2024:

{     "from": "2024-05-15",     "to": "2024-05-15" }

The body can contain just "from", or just "to" element. If the body of the request is empty {} then the export will include deleted MARC bibliographic records for the previous day.

The response will contain jobExecutionId that will be needed if monitoring of the export and accessing generated files is to be scripted.

{ "jobExecutionId": "ce244168-2878-4ffd-9888-e5e67fec35eb" }

 

Starting export of deleted MARC authority records [released in Ramson]

MARC authority records is considered deleted if its LDR05 is set to “d”. The export of the deleted authority records can be triggered only via API. The export job can be monitored via API calls or directly in the Data export app.

To start the export send POST request to {{url}}/data-export/export-authority-deleted endpoint with valid folioAccessToken and Content-type set to application/json.

The request supports following parameters:

offset

integer [ 0 .. 2147483647 ]

Default: 0

Skip over a number of elements by specifying an offset value for the query.

Limit

integer [ 0 .. 2000 ]

Default: 100

Limit the number of elements returned in the response.

query

string

Default: "cql.allRecords=1"

A query expressed as a CQL string (see dev.folio.org/reference/glossary#cql) using valid searchable fields. Authorities can be queried using the following fields: headingType, authoritySourceFile.id, authoritySourceFile.name, createdDate, updatedDate.

Example:

"query":"(authoritySourceFile.name=\"LC Name Authority file (LCNAF)\" and (updatedDate>2024-09-02T12:00:00.0))"

All records are exported using the Deleted authority export profile job.

The response contains jobExecutionId that can be used to monitor progress of the export job and later to retrieve files generated by export via API calls.

image-20240822-185623.png

Monitoring progress and downloading files generated by export job in Data export app

After the export job is triggered by API call, its progress can be monitored in the Data export app. If the job is successful then the generated files can be retrieved in the UI as well. The MARC bib records will be exported with the Default instances export job profile. The MARC authority records will be exported with the Deleted authority export job profile.

Files generated by the export job will be named:

  • deleted-marc-bib-records-<export-job-hrid>.mrc for MARC bib records

  • deleted-authority-records-<export-job-hrid>.mrc for MARC authority records

If the export contains more than 100 000 records then the multiple files are compressed (zipped) and named deleted-marc-bib-records-<export-job-hrid>.zip or deleted-authority-records-<export-job-hrid>.zip. There will be only one link for downloading those files.

image-20240822-192900.png

If there query did not return any matching records, the job will complete with status Fail, the number of Total and Exported records will be 0:

The error displayed when the user clicks on the row with the failed job will read: Error while reading from input file with uuids or file is empty.

Monitoring progress of the export job via API call

This step is asynchronous and will require a polling loop by posting GET request to /data-export/job-executions?query=id=="<jobExecutionId>" endpoint. The property jobExecutionId is the value from the response to {{url}}/data-export/export-deleted (see step before)

Stop pooling when the status is either SUCCESS or FAIL. The response will be similar to:

{ "id": "22091d4a-0c70-4a9e-8843-5dcf96c7cdf5", "hrId": "112", "exportedFiles": [ { "fileId": "b975b199-fa3c-4cc8-8257-4e996e64addb", "fileName": "test-112.mrc" } ], "jobProfileId": "6f7f3cd7-9f24-42eb-ae91-91af1cd54d0a", "jobProfileName": "Default job profile", "progress": { "exported": 25, "failed": 0, "total": "25" }, "completedDate": "2023-10-07T13:18:20.364+0000", "startedDate": "2023-10-07T13:18:19.852+0000", "runBy": { "firstName": "admin", "lastName": "admin" }, "status": "SUCCESS" }

 

Once the polling loop ends, the job id (id in the screenshot above) and the file id (fileId in the screenshot above) will be needed for downloading the file generated by the export.

Downloading files generated by export job via API call

To download the file send GET request to /data-export/job-executions/<id>/download/<fileId> endpoint. The response will contain two fields; fileId and link. Use the link to download the file.