我在.net中使用Restsharp作为web api客户端。我尝试了多种排列,但仍无法正常工作。它出现以下错误:
连接失败 系统返回: (13)许可被拒绝。
非常感谢任何帮助。
curl -v -H "Content-Type: application/json; charset=UTF-8" -X POST -d "{\"name\":\"ask question from mediator1\",\"title\":\"ask question from mediator\",\"abstractText\":\"ask question from mediator\",\"editorialService\":\"CHINA\",\"plcRef\":\"a-000-2000\"}" http://mynetworkserver:8081/ask/asset
我正在使用的代码:
RestClient client = new RestClient();
client.BaseUrl = "http://mynetworkserver:8081/ask/asset"; // **Is this url correct?**
RestRequest request = new RestRequest(Method.POST);
var fQuestion = new FQuestion
{
name = "ask question from mediator 1",
title = "ask question from mediator",
abstractText = "ask question from mediator",
editorialService = "CHINA",
ref = "A-000-0023"
};
request.RequestFormat = DataFormat.Json;
request.Resource = "asset"; **// What is this?**
request.AddHeader("Content-Type", "application/json");
request.AddBody(fQuestion);
IRestResponse response = client.Execute(request);