Forum Discussion

Aadi12's avatar
Aadi12
Explorer | Level 4
2 years ago

Error, When using Batch Operation

hello, 
When I use batch operation like Create folder in batch
The operation perform but it show this kind of error 
Indivisual operation like Create folder, Copy File is working fine and give the JSON also but in Batch operation this error

Cannot convert to JSON, detail: Invalid tag: required Tag.COMPLETE, but was Tag.ASYNC_JOB_ID (through reference chain: com.dropbox.core.v2.files.CreateFolderBatchLaunch["completeValue"])




  • Rich's avatar
    Rich
    Icon for Super User II rankSuper User II

    Aadi12 wrote:

    Error, When using Batch Operation


    Is this something you're doing through the Dropbox API? If so, I'll move your post to the appropriate section for help with the API.

    • Aadi12's avatar
      Aadi12
      Explorer | Level 4

      Yes, I make Custom Snap Using API

       

  • Greg-DB's avatar
    Greg-DB
    Icon for Dropbox Staff rankDropbox Staff

    Aadi12 It looks like you're using the Dropbox Java SDK to create some folders. When using createFolderBatch or createFolderBatchBuilder functionality, the resulting CreateFolderBatchLaunch may indicate either "launch an asynchronous job or complete synchronously". That being the case, you'll need to check which type it is before attempting to use it as that type.

     

    The error you're getting indicates that you're calling CreateFolderBatchLaunch.getCompleteValue on an object that isn't tagged as "complete". You should call CreateFolderBatchLaunch.isComplete first; only if that returns true should you then use CreateFolderBatchLaunch.getCompleteValue.

     

    You should likewise use CreateFolderBatchLaunch.isAsyncJobId to check if it is instead an async job ID, and if so then use CreateFolderBatchLaunch.getAsyncJobIdValue to get the value and use createFolderBatchCheck to check on the job.

     

    For example, if you're doing something like this:

    CreateFolderBatchLaunch createFolderBatchLaunch = client.files().createFolderBatch(foldersToCreate);

    Then just doing this would be incorrect, since you're not checking if the object is actually "complete" first:

    System.out.println(createFolderBatchLaunch.getCompleteValue());

    Instead, you need to do something like this:

    if (createFolderBatchLaunch.isComplete()) {
        System.out.println(createFolderBatchLaunch.getCompleteValue());
        // handle completed operation as desired...
    } else if (createFolderBatchLaunch.isAsyncJobId()) {
        System.out.println(createFolderBatchLaunch.getAsyncJobIdValue());
        // use createFolderBatchCheck to poll for the job status...
    } else {
        // fallback behavior...
    }

     

    • Aadi12's avatar
      Aadi12
      Explorer | Level 4

      Thank you !. Error have resolved