Search code examples
javaspringopentoktokbox

Start archiving in opentok java sdk v4.3.0 results in 400 (Bad Request)


I am using tokbox opentok project for publishing and subscribing video camera and also archiving them. I was using opentok-java-sdk v2.3.2 in which everything was working fine until I changed the sdk version. Now I have changed the sdk version to 4.3.0. which is resulting in start archiving failure.
It gives me the following error:

com.opentok.exception.RequestException: Could not start an OpenTok Archive. A bad request, check input archive properties like resolution etc.
    at com.opentok.util.HttpClient.startArchive(HttpClient.java:259)
    at com.opentok.OpenTok.startArchive(OpenTok.java:445)
    at com.abc.web.utils.OpenTokSdkUtils.startRecording(OpenTokSdkUtils.java:99)

If anyone could help me out with this. That would be really appreciated.
Edit:- I am following this code from the opentok guide for java sdk

import com.opentok.Archive;
import com.opentok.ArchiveProperties;

Archive archive = opentok.startArchive(sessionId, new ArchiveProperties.Builder()
  .archiveMode(Archive.OutputMode.INDIVIDUAL)
  .build());

// Store this archiveId in the database for later use
String archiveId = archive.getId();

But this has a problem with ArchiveBuilder as archive builder has no method name archiveMode, so I used the outputMode which I was using previously.
After changes:-

Archive archive = opentok.startArchive(sessionId, new ArchiveProperties.Builder()
                      .outputMode(Archive.OutputMode.INDIVIDUAL).name(username)
                      .build());

Solution

  • TokBox Developer Evangelist here.

    It looks like the OpenTok Java SDK is attempting to add a layout even when the outputMode is set to Archive.OutputMode.INDIVIDUAL. I've gone ahead and filed a bug in the SDK repo so you can track the patch release.

    Please check out the API docs for more information on archiving: https://tokbox.com/developer/rest/#start_archive