首页 > 解决方案 > 我想创建一个简单的 dotnet(vb.net 或 c#.net) 类

问题描述

我有一个小任务。我需要创建一个与 RPC REST 服务通信的 .net 类库。我需要的只是基本框架。因此,如果您可以让它传递 API 令牌并取回登录凭据 https://simplybook.me/en/api/developer-api/tab/explorer_api

The have a sample API Key I think you can use:

company: mib
API key: f43618e37b82004066d60db3431f4a06392599a6cfcafa8268bf25becc0ec7d7

标签: c#vb.netapi

解决方案


您可以使用 JSONRPC 客户端,如下所示链接

using (Client rpcClient = new Client("someURL"))
{
    rpcClient.Headers.Add("X-Application", "MyApplicationKey");

    Request request = rpcClient.NewRequest("SportsAPING/v1.0/listMarketBook");
    GenericResponse response = rpcClient.Rpc(request);

    if (response.Result != null)
    {
        JToken result = response.Result;
    }
    else
        Console.WriteLine(string.Format("Error in response, code:{0} message:{1}",
            response.Error.Code, response.Error.Message);


    // Example with positional parameters
    JArray parameters = JArray.Parse(@"['Small', 'Medium', 'Large' ]");
    Request resuestWithPostionalParameters = rpcClient.NewRequest("SportsAPING/v1.0/listMarketBook", parameters);

    // Example with named parameters
    JObject namedParameters = JObject.Parse(@"{ CPU: 'Intel', }");
    Request resuestWithNamedParameters = rpcClient.NewRequest("SportsAPING/v1.0/listMarketBook", namedParameters);
}

推荐阅读