我已经通过http://restsharp.org/代码,这很好用。下面是带有asp.net内核的RestSharp的代码。如何在asp.net核心中使用RestSharp.NetCore
public GenericResponseObject<T> GetGeneric<T>(string operation, params KeyValuePair<string, string>[] nameValues) where T : class
{
RestClient client = new RestClient(_baseUrl)
{
Authenticator = new HttpBasicAuthenticator(_username, _password)
};
RestRequest request = new RestRequest(operation, Method.GET);
foreach (KeyValuePair<string, string> nameValue in nameValues)
{
request.AddQueryParameter(nameValue.Key, nameValue.Value);
}
IRestResponse<GenericResponseObject<T>> response = client.Execute<GenericResponseObject<T>>(request);
GenericResponseObject<T> responseObject = response.Data;
return responseObject;
}
}
此代码对我很好。现在我想在asp.net核心中实现相同的代码。
我可以得到一个示例如何在asp.net核心中使用RestSharp。我已经添加了依赖RestSharp.NetCore“:105.2.3
我想用RestSharp.NetCore ...... –
的问题已经为RestSharp.NetCore具体要求,就这样吧。回应它已经坏了/不能用/等等,然后**也许**推荐另外一件事,如果你真的觉得自己有兴趣做广告...... OTOH。只是推荐像你这样做的另一件事就像对“如何在C#中做Foo?”的Q&A一样没有帮助? - “重新:使用Java代替”。 – quetzalcoatl