Page 1 of 1

Can't make serverInfo method work in C#

Posted: Fri Nov 02, 2018 1:41 pm
by Demeisen
So I want to make a small personal project with C# and OS API. I thought I would start just by testing the serverInfo function since this is my first time working with xml-rpc and OS API, and I ran into a problem. This is my code:

Code: Select all

namespace OSApp { public class response { public string xmlrpc_version { get; set; } public string xmlrpc_url { get; set; } public string application { get; set; } public string contact { get; set; } public string website_url { get; set; } public int users_online_total { get; set; } public int users_online_program { get; set; } public int users_loggedin { get; set; } public string users_max_alltime { get; set; } public string users_registered { get; set; } public string subs_downloads { get; set; } public string subs_subtitle_files { get; set; } public string movies_total { get; set; } public string movies_aka { get; set; } public string total_subtitles_languages { get; set; } public Dictionary<string, string> last_update_strings { get; set; } public double seconds { get; set; } } [XmlRpcUrl("http://api.opensubtitles.org/xml-rpc")] public interface FlRPC : IXmlRpcProxy { [XmlRpcMethod("ServerInfo")]//endpoint name response ServerInfo(); } public class Program { public static void Main() { response testRes = new response(); FlRPC proxy = XmlRpcProxyGen.Create<FlRPC>(); proxy.ServerInfo(); } } }
I get this exception:

Code: Select all

Unhandled Exception: CookComputing.XmlRpc.XmlRpcTypeMismatchException: response contains struct value with missing non-optional members: Item Keys Count Values Comparer [response : struct mapped to type response : member last_update_strings mapped to type Dictionary`2 : struct mapped to type Dictionary`2]
It says in the documentation that users_online_total, users_online_program, users_loggedin should be strings but I got exceptions there that said that int is expected so I changed them to int. Now the problem is with last_update_strings. I tried several different classes there, Dictionary, List, Array, making a new class, initializing it, but clearly I am missing something because the structure of last_update_strings is wrong. Anyone know how to solve this?

Re: Can't make serverInfo method work in C#

Posted: Sat Nov 17, 2018 5:45 am
by oss
I am not a C# programmer, I believe there are some programs in C#, which are using our API. Could you debug the response ? In PHP and other languages it is easy, we just make print_r($response) and can see all the data structure which can be handled later accordingly.

sorry I can not really help here