Forum rules
Under no circumstances is spamming or advertising of any kind allowed. Do not post any abusive, obscene, vulgar, slanderous, hateful, threatening, sexually-orientated or any other material that may violate others security. Profanity or any kind of insolent behavior to other members (regardless of rank) will not be tolerated. Remember, what you don’t find offensive can be offensive to other members. Please treat each other with the kind of reverence you’d expect from other members.
Failure to comply with any of the above will result in users being banned without notice. If any further details are needed, contact: “The team” using the link at the bottom of the forum page. Thank you.
Posts: 1
Joined: Fri Nov 02, 2018 1:24 pm

Can't make serverInfo method work in C#

Fri Nov 02, 2018 1:41 pm

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; }

    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>();

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?

User avatar
Site Admin
Posts: 4514
Joined: Sat Feb 25, 2006 11:26 pm
Contact: Website

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

Sat Nov 17, 2018 5:45 am

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

Return to “Developing”

Who is online

Users browsing this forum: No registered users and 27 guests