Asynchronous Jobs and Task Status - PaperCutSoftware/PaperCutExamples GitHub Wiki

Special Note on Asynchronous Jobs

Some methods, that deal with a large amount of data, do not wait for job completion before returning to the client. These methods are:

  • addNewUsers()
  • addNewGroup()
  • adjustUserAccountBalanceByGroup()
  • adjustUserAccountBalanceByGroupUpTo()
  • batchImportInternalUsers()
  • batchImportSharedAccounts()
  • batchImportUserCardIdNumbers()
  • batchImportUsers()
  • performGroupSync()
  • performUserAndGroupSync()
  • performUserAndGroupSyncAdvanced()
  • performOnlineBackup()
  • setUserAccountBalanceByGroup()
  • syncGroup()

Because all these operations take an extended time to complete the API will return immediately to the caller and the operation will complete asynchronously. It is the client's responsibility to use the getTaskStatus() method to ensure the operation has completed and was successful.

The getTaskStatus() call returns a simple structure with:

  • A boolean status result completed which is false until the operation is complete
  • A text string, message, that provides extended information on the result of the operation.

Please note that currently getTaskStatus() method :

  • does not take an authentication parameter, unlike all the other API calls.
  • will only check the status of the last job submitted. You should wait for the job to complete before starting another asynchronous method call.

The logic is as follows

images/getTaskStatus.png

See here for an example Python program than illustrates this process.