Help i'cant execute startSession

I can’t execute camera.startSession of a theta z1
“fingerprint”: “FIG_0002”,
“_apiVersion”: 2,
“batteryLevel”: 0.5,
“_batteryState”: “disconnect”,
“_captureStatus”: “idle”,
“_capturedPictures”: 0,
“_compositeShootingElapsedTime”: 0,
“_function”: “normal”,
“_latestFileUrl”: “”,
“_mySettingChanged”: false,
“_pluginRunning”: false,
“_pluginWebServer”: true,
“_recordableTime”: 0,
“_recordedTime”: 0,
“storageUri”: “

You don’t need startSession for the Z1.

The start session is only required for the SC.

The API for the Z1 is largely the same as the SC2 for basic commands.

There re many examples here:

Post again if you continue to have problems.

1 Like

I already managed to takePicture, now I don’t know how to save that image on the computer, I’m working in Javascript
Help Please

1 Like
/// This example uses osc/commands/status to get the state of takePicture,
/// then it uses osc/state to get the URL of the file for download.
/// The full process is:
/// 1. takePicture
/// 2. check on status of take picture and make sure state is done
/// 3. if the status does not show state as done, then loop back to the check
/// 4. if the status shows state as done, then get the URL of the last image with state
/// 5. download file and save to disk.  This only works on the command line
import 'dart:io';
import 'dart:convert';
import 'package:http/http.dart' as http;
import 'package:apitest/download_ready.dart';
import 'package:apitest/firmware_version.dart';

Future<String> takeAndDownload() async {


  String readyStatus = await downloadReady();

  if (readyStatus == "ready") {
  var url ='';

  var response = await,
      headers: {"Content-Type": "application/json;charset=utf-8"}

  Map<String, dynamic> thetaState = jsonDecode(response.body);

  // print(thetaState);
  String imageFileUrl = thetaState['state']['_latestFileUrl'];
  print("Writing file from the following URL");

  String imageFileName = imageFileUrl.split("/")[6];
    await File(imageFileName).writeAsBytes(await http.readBytes(imageFileUrl));
    print("download complete");
    return "success";
  } else {
    print("download failed");
    return "fail";

Check That File Is Ready to Download

import 'dart:async';
import 'dart:convert';
import 'package:http/http.dart' as http;
import 'package:apitest/commands/take_picture.dart';

Future<String> isDone(String id) async {
  var url ='';
  Map data = {
    'id': id

  var payload = jsonEncode(data);

  var response = await,
      headers: {"Content-Type": "application/json;charset=utf-8"},
      body: payload

  Map<String, dynamic> status = jsonDecode(response.body);
  String state = status['state'];
  return state;

Future<String> downloadReady () async {

  print("Test of taking picture and then checking to see if picture is ready for download");
  var takePictureResponse = await takePicture();
  // print(takePictureResponse);
  Map<String, dynamic> pictureInfo = jsonDecode(takePictureResponse.body);
  String id = pictureInfo['id'];
  print('The status ID is $id');

  bool keepGoing = true;
  int elapsedSeconds = 0;  

  while (keepGoing) {
    var currentStatus = await isDone(id);
    // print(currentStatus);

    await new Future.delayed(const Duration(seconds: 1));
    print("Elapsed time: $elapsedSeconds seconds. State: $currentStatus");
    if (currentStatus == "done") {
      keepGoing = false;

  // String fileUrl = await getLastImageUrl();
  print("picture ready for download");
  return 'ready';
1 Like

would this command line apply to flutter?

The example above only shows the THETA-specific functions. Once you have the image in your mobile app, you need to use one of the numerous packages to save the file to either Android/iOS.

For example, to save to local storage, you would need to extend for iOS/Android file system support with something like this:

I’m assuming that your main issue is how to check to make sure the image is ready to download after you take a picture. The fileUri on the camera can be pulled with an HTTP GET. Once you have the THETA image in system memory on your app, then save it to file. The method to save the file to local storage is dependent on the underlying OS (Android, iOS, Linux, Windows).

1 Like

Hello Craig.

What about camera._start_capture for Z1? How I can starting capture, if this command need parameter session ID, and this parameter should return after camera.startSession command.

Unfortunately, documentation is not transparently.
P.S. Where I can get command list only for Z1?

use api version 2.1

The Z1 does not use session ID with startCapture. Refer to API version 2.1


OLD Version - Do not use version 2.0


Supporting older cameras

If you need to support the SC and S in addition to he Z1, use state to get the apiVersion and identify if if is is using API 2 (V, Z1) or API 1 (SC, S).