RICOH THETA Client Mode with Java

Can I do the same with android Java basciacally I need to make a HttpURLConnection from android to the Theta camera. It is working when theta is connected via Access Mode and not working when its in client mode basically we are getting java.io.FileNotFoundException

JSONObject input = new JSONObject();
        InputStream is = null;
        try {
            input.put("name", "camera.getLivePreview");
            final URL url = new URL("http://192.168.18.47/osc/commands/execute");
            Authenticator.setDefault(new Authenticator() {
                @Override
                protected PasswordAuthentication getPasswordAuthentication() {
                    return new PasswordAuthentication("THETAYLXXXXXXXX", "XXXXXXXX".toCharArray());
                }
            });
            final HttpURLConnection connection = (HttpURLConnection) url.openConnection();
            connection.setRequestProperty("Content-Type", "application/json;charset=utf-8");
            connection.setRequestProperty("Accept", "application/json");
            connection.setRequestProperty( "X-XSRF-Protected", "1" );
            connection.setDoInput(true);
            connection.setRequestMethod("POST");
            connection.connect();
            OutputStream os = connection.getOutputStream();
            os.write(input.toString().getBytes());
            is = connection.getInputStream();
            final byte[] buffer = new byte[8196];
            int readCount;
            final StringBuilder builder = new StringBuilder();
            while ((readCount = is.read(buffer)) > -1) {
                builder.append(new String(buffer, 0, readCount));
            }
            final String response = builder.toString();
        }
        catch (IOException e) {
            e.printStackTrace();
        }

Are you using Digest Authentication and not basic authentication for the HTTP request?

BTW, the Z1 may be a better model to use as the V is discontinued.

See the examples below for testing the client mode with curl and other tools.

I tried Digest Authentication and basic authentication both are giving java.io.FileNotFoundException when its from client mode. I’m able to get it working from desktop cmd tool using the curl commands .But our requirement is to connect it from the android application using client mode and execute the camera.getLivePreview. When we connect to theta camera wifi in device it worked with out authentication but switching to clientmode always giving fileNotFound exeception.If you have any examples for trying it using android java will be helpful. Thank You.

Does your code work if you disable client mode authentication? Please try without the username and password. You first need to set the _authentication option to none

I’m not sure why this option is no longer listed in the documentation.

Also, I’ll try and find an example of the Java client mode.