I expect there are syntax errors or some such things. I am trying to communicate with a Theta V and got some results, but usually I get 400’s.
var url = "http://192.168.1.1/osc/commands/execute";
// following works
string data = "{'name': 'camera.listFiles','parameters': {'fileType': 'image','entryCount': 2,'maxThumbSize': 0}}";
// api 2.1 these return 400s
//string data = "{'name': 'camera.getOptions','parameters': {'optionNames': ['iso', 'isosupport']}}";
//string data = "{'name': 'camera.setOptions','parameters': {'options': {'iso': 200}}}";
//string data = "{'name': 'camera._getMySetting','parameters': {'optionNames': ['_filter', 'exposureProgram']}}";
// api 2.0 this returns a 400
//string data = "{'name': 'camera.startSession'}";
var client = new HttpClient();
HttpContent content = new StringContent(data, Encoding.UTF8, "application/json");
var response = await client.PostAsync(url, content);
if (response.StatusCode == HttpStatusCode.OK)
{
string responseString = await response.Content.ReadAsStringAsync();
Dictionary<string, object> r_Data = JsonConvert.DeserializeObject<Dictionary<string,
object>>(responseString, new JsonSerializerSettings { NullValueHandling = NullValueHandling.Ignore });
foreach (var t in r_Data)
{
Debug.WriteLine(t.Key + " : " + t.Value);
Reply.Text += t.Key + " : " + t.Value + "\n";
}
}
else
{
Debug.WriteLine("Did not connect. " + response.ToString());
}
The 400s look something like this:
[0:] Did not connect. StatusCode: 400, ReasonPhrase: ‘Bad Request’, Version: 1.1, Content: System.Net.Http.StreamContent, Headers:
{
Connection: Keep-Alive
X-Android-Received-Millis: 1594648803333
X-Android-Response-Source: NETWORK 400
X-Android-Selected-Protocol: http/1.1
X-Android-Sent-Millis: 1594648803203
X-Content-Type-Options: nosniff
Content-Length: 173
Content-Type: application/json; charset=utf-8
}
Because camera.listFiles works and it is unique to API2.1, I tried a few more commands from 2.1. No luck. None from 2.0 either.
Any insight as to what I am missing would be greatly appreciated.