Comments (4)
Hi i try it but i became a error:
System.ArgumentException: "Could not determine JSON object type for type <>f__AnonymousType1`3[System.Int32,System.String,System.String]."
But for the readme i can create the object with:
dynamic jsonObject = new JObject();
jsonObject.method = "dnld_install_sound";
jsonObject.@params = new JObject();
[email protected] = 1;
[email protected] = ws.baseurl + localfile.Replace("\\", "/");
[email protected] = CalculateMD5(localfile);
Thank you i use this lines.
from dlid.mihome.
Hi!
The Send-method that accept the method name is meant for the average command - I believe most of them will take an array of parameters so that's why I created this overload to easily invoke most commands.
But is a version of Send - Send(object data)
- that will allow you to send any data, but then you must also specify the method name in your object.
dynamic jsonObject = new JObject();
jsonObject.method = "dnld_install_sound";
jsonObject.@params = new {
sid = 1,
url = (ws.baseurl + localfile.Replace("\\", "/")),
md5 = CalculateMD5(localfile)
};
var device = new MiDevice(**IP**, **TOKEN**);
device.Send(jsonObject);
I hope that will make it possible for you to create your install_sound request properly.
Regards
David
from dlid.mihome.
Ah ok, I never tried it out with the JObject so I take it it's an issue with how that one is serializing anonymous objects .
I usually just use anonymous objects so I would choose to do it like this:
using(var device = new MiDevice("**IP**", "**TOKEN**")) {
device.Send(new {
method = "dnld_install_sound",
@params = new {
sid = 1,
url = (ws.baseurl + localfile.Replace("\\", "/")),
md5 = CalculateMD5(localfile)
}
});
}
Glad it worked out though!
from dlid.mihome.
Ok yes this work too. But i love the dynamics a little more, when i want i can extend the dynamic at a later point ;)
var test = new {
method = "dnld_install_sound",
@params = new {
sid = 1,
url = (ws.baseurl + localfile.Replace("\\", "/")),
md5 = CalculateMD5(localfile)
}
};
from dlid.mihome.
Related Issues (5)
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from dlid.mihome.