【发布时间】:2020-10-17 08:50:53
【问题描述】:
我正在尝试对第 3 方 Web api 进行测试。 如何发布的代码由第 3 方的文档提供。
'RestClient' is a namespace but is used like a type
The type or namespace name 'RestRequest' could not be found (are you missing a using directive or an assembly reference?)
The type or namespace name 'IRestResponse' could not be found (are you missing a using directive or an assembly reference?)
The name 'ParameterType' does not exist in the current context
The name 'Method' does not exist in the current context
我正在使用的方法:
public void CreatePanelists (Newtonsoft.Json.Linq.JObject data)
{
Parameters parameters = JsonConvert.DeserializeObject<Parameters>(data.ToString())
IList<Panelist> panelistList = parameters.panelists;
string id = parameters.id;
var client = new RestClient("https://3rdparty.com/v2/events/5893/atendees");
var request = new RestRequest(Method.POST);
request.AddHeader("content-type", "application/json");
request.AddHeader("authorization", "Bearer vJRMZ92lsOE1sKGVF7_4zCezTjxO2RoFeOVGULSJS2_dRhgU5QfZeKqGaoS0ogPv0WISEuZ1RcNzJDUsv27uGA");
request.AddParameter("application/json", "{\"attendees\":[{\"name\":\"Mary\",\"email\":\"maryjkdfdsgfshdgf@jdfdkjdglfk.jkfgdj\"},{\"name\":\"Mike\",\"email\":\"dfdsgfsdhf@jkgfdgfkdhgfdjg.fkjgdf\"}]}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
}
我安装了 RestClient 4.0.0,但这并没有消除错误。
我没有使用 .Net 而不是 .net Core。我错过了什么?
第一次开发此类项目,如果我的技术语言不正确,请原谅。
非常感谢您的帮助。
谢谢你, 伊拉斯莫
更新 - 我能够安装 RestSharp 版本 106.11.4.0 和 RestClient 版本 2.5.0.6。
唯一持续的错误是
'RestClient' is a namespace but is used like a type
【问题讨论】:
标签: c# asp.net-mvc rest asp.net-web-api