0

I am using Open tok rest api. and specifying " archiveMode:always " while creating session and they have specified in documentation that as soon as any one subscribe to session it will start archiving the session but it is not my code is as follows

    final WSRequest request = WS.url("https://api.opentok.com/session/create");
    // request.setContentType("application/json");
    request.setHeader("X-TB-PARTNER-AUTH", Constants.OPENTOK_API_KEY+":"+Constants.OPENTOK_SECRET);
    request.setHeader("archiveMode","always");

    request.setMethod("POST");
    final Promise<WSResponse> response = request.execute();   //post("X-TB-PARTNER-AUTH:"+ApiCredentials.apiKey+":"+ApiCredentials.apiSecret);

    final Function<WSResponse,Document> resultFromResponse =
            new Function<WSResponse   , Document   >() {


        @Override
        public Document apply(final WSResponse arg0) throws Throwable {
            // TODO Auto-generated method stub
            //String message = response.get(0).asXml().getBaseURI();
            Logger.debug(""+response.get(0).getBody());
            final Document doc  = response.get(0).asXml();
            final Result result =ok("temp value");
            return doc;
        }

    };
    final Promise<Document> resultDoc= response.map(resultFromResponse);
    final Document document = resultDoc.get(1000*10l);

    if(document == null) {
        return null;
    } else {
        Logger.debug("document:"+document);
        final String name = XPath.selectText("//session_id", document);
        Logger.debug("sessionid:"+name);
        if(name == null) {
            return null;
        } else {

            sessionId = name;

            //return ok("Hello " + name);
        }
    }
Tim B
  • 40,716
  • 16
  • 83
  • 128
Mitesh Ukate
  • 173
  • 2
  • 14

1 Answers1

0

The "archiveMode" key is not an HTTP header, it's part of the HTTP POST body.

Ankur
  • 2,792
  • 3
  • 23
  • 26
  • export api_key=12345 # replace with your API key export api_secret=123456123456123456 # replace with your API secret export TB_url=https://api.opentok.com/session/create authstr="X-TB-PARTNER-AUTH:$api_key:$api_secret" datastr=archiveMode:always \ curl \ -X POST \ -H "Accept:application/json" \ -H "$authstr" \ -H "$datastr" \ $TB_url
    This is the example from their rest api
    – Mitesh Ukate Nov 13 '15 at 06:58