我在 .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);