THETA V and THETA Z1 not answering web requests from C# app

Greetings,

I am trying to send https requests to theta V and theta Z1, but I have no anwsers :

Theta V:
I can get info and state (http://192.168.1.1/osc/state and http://192.168.1.1/osc/info)
I can start the session (camera.startSession)
I can take a picture (camera.takePicture)

I can’t get anwser for any other command.

Theta Z1:
Only state and info are working.

I tried with theta SC, and everything works.
Firmwares are updated.
I send an email to the support, but I got the following anwser :
“We don’t support the API and SDK issues”* (translated*)

(i’m using c#)

I hope you can help me !

1 Like

Are you passing this in the header?

Content-Type: application/json;charset=utf-8

I did another test. The command is successful with a content-type header. It will fail without the header. Test is with a Z1.

POST /192.168.1.1/osc/commands/execute HTTP/1.1
Content-Length: 63
Host:
Content-Type: application/json;charset=utf-8

{
    "name": "camera.takePicture",
    "parameters": {
    }
}

HTTP/1.1 200 OK
Connection: Keep-Alive
X-Content-Type-Options: nosniff
Content-Length: 91
Content-Type: application/json; charset=utf-8

{"id":"78","name":"camera.takePicture","progress":{"completion":0.00},"state":"inProgress"}

image

2 Likes

Hey, thank you for anwsering !
I didnt try the charset.

I’ll try this out and come back to you then.

2 Likes

If you get another error, can you post the exact HTTP response back? You can either copy and paste or take a screenshot.

It might say something under HTTP/1.1 404… with more information.

Ideally, it will say, HTTP/1.1 200 OK … and everything will be hapy.

Greetings,

Thank you for your help. I finaly can talk kindly with my cameras !

I added chartset=utf-8 to my Content-Type although the problem was not there.

Theta V and Theta Z1 don’t use the camera.startSession command that I was doing no matter which camera I was using. It actualy just needs the basic request to work. I figured it out thank to your screens.

Thank you again.

Best regards,
Samuel

2 Likes

Samuel, thank you for the report back on success.

I should have thought of this and pointed it out to you. The SC and S use an older version of the API by default and need to be told to use the newer API. The V and Z1 use the newer API by default. I’ve struggled with this in the past myself.

https://developers.theta360.com/en/docs/v2.1/api_reference/getting_started.html

It’s explained in the official documentation, but easy to overlook and IMO, would benefit from more examples.

2 Likes

Issues are hidden behind issues…

Again with Theta V and Theta Z1, I can send one request, but the request following will block with no anwser.

I’m not using anymore unhandled methods like camera.startSession and I have the correct content type Content-Type: application/json;charset=utf-8. It works on Reslet properly, I can send multiple requests, but when I try on an app, the first request works (whatever the request is), and the second will have no anwser.

Hi,

On The Theta SC there is no problem using Webrequests to send http requests.
But on Theta V and Theta Z1, it works for only 1 - 2 requests. The best way to make it work is by using HttpClient.

I hope it will help c# users.

2 Likes

I see from Microsoft docs that HttpClient provides a base class for sending/receiving HTTP requests/responses from a resource identified by a URI. This seems very straightforward. How did you find this solution?

THETA V and Z1 are Android OS-based devices. THETA SC is not. Without knowing the details, I’m guessing that’s related.

Congrats on fixing the issues and thanks for posting for the community!

What’s the next step? :slight_smile:

@jcasman can you post the link to the C# documentation? I’m not sure what the difference is between .NET Framework and C#.

I found this example, which looks straightforward.

https://www.dotnetperls.com/httpclient

In general, I like C#, but have primarily used it for Unity. As far as I can tell, the language has great tools and features that I like. I personally like typed languages and don’t like the lack of enforcement with Python or JavaScript. C# programs can also be quite fast compared to scripting languages.

1 Like

This is the documentation I was referring to:

https://docs.microsoft.com/en-us/previous-versions/visualstudio/hh193681(v=vs.118)

I found here someone using this class, so I gave it a shot and it worked.

The community helps me, seems fair to help the community !

Now I’m working on getting the response stream, and since HttpClient is all asynchronous, I’ll might be able to update the image source for the preview !

2 Likes

@Samuel.L, just checking in, how’s the project going?

Hi,

Sadly I am blocked with the stream ! I can’t manage to get it with the methods provided by the HttpClient class.

Microsoft documentation says the stream is returned after the headers have been read, but none of the method giving the stream or reading the headers are executed.

As you can see, I am still struggling with it.