这可能过于具体,无法解决援助问题,但我遇到了障碍,不知道还有什么地方可以解决。
我通过REST API发布到网站,他们的文档声明:
var client = new RestClient("https://server_name/api/import/tickets");
var request = new RestRequest(Method.POST);
request.AddHeader("authorization", "Bearer {{access_token}}");
request.AddHeader("content-type", "application/json");
request.AddHeader("accept", "application/json");
var yourArrayOfTickets = new List<Ticket>();
// TODO: populate the list
request.RequestFormat = DataFormat.Json;
request.AddBody(yourArrayOfTickets);
IRestResponse response = client.Execute(request);
我发送
public static void MakeTicket(string token, string url,
string clientName, string clientLocation,
string ticketSource, string ticketType,
string title, string priority, string status,
string details, DateTime openDate, string queue)
{
TicketBody ticketBody = new TicketBody();
ticketBody.ClientName = clientName;
ticketBody.ClientLocation = clientLocation;
ticketBody.TicketSource = ticketSource;
ticketBody.TicketType = ticketType;
ticketBody.Title = title;
ticketBody.Priority = priority;
ticketBody.Status = status;
ticketBody.Details = details;
ticketBody.OpenDate = Convert.ToString(openDate.ToString("MM/dd/yyyy HH:mm:ss"));
ticketBody.Queue = queue;
var body = JsonConvert.SerializeObject(ticketBody);
var bodyList = new List<string>();
bodyList.Add(body);
var client = new RestClient(url + "/import/tickets");
var request = new RestRequest(Method.POST);
request.AddHeader("authorization", "Bearer " + token);
request.AddHeader("content-type", "application/json");
request.AddHeader("accept", "application/json");
request.RequestFormat = DataFormat.Json;
request.AddBody(bodyList);
IRestResponse response = client.Execute(request);
}
错误信息太模糊了,无法帮助我,它只是说我错过了一些东西,但没有说出什么,据我所知,我正在传递它所需要的一切。
答案 0 :(得分:0)
根据文档屏幕截图,您尚未包含必需参数AssgineeUsername
。如果您指定Queue
,请尝试将其传递为空,但请将其包含在请求中。
ticketBody.Queue = queue;
ticketBody.AssgineeUsername = "";
答案 1 :(得分:0)
事实证明我为此错误地构建了JSON对象。它不是序列化整个对象,而是一个列表。
[u'Windows', u'Fusion']