我想使用RestSharp在JIRA中创建一个POST请求来创建问题,我必须使用的是使用cURL的示例。我不知道我做错了什么。从cURL请求翻译RestSharp POST请求
下面是卷曲给出的example:
curl -D- -u fred:fred -X POST --data {see below} -H "Content-Type: application/json"
http://localhost:8090/rest/api/2/issue/
这里是他们的榜样数据:
{"fields":{"project":{"key":"TEST"},"summary":"REST ye merry gentlemen.","description":"Creating of an issue using project keys and issue type names using the REST API","issuetype":{"name":"Bug"}}}
这里就是我试图与RestSharp:
RestClient client = new RestClient();
client.BaseUrl = "https://....";
client.Authenticator = new HttpBasicAuthenticator(username, password);
....// connection is good, I use it to get issues from JIRA
RestRequest request = new RestRequest("issue", Method.POST);
request.AddHeader("Content-Type", "application/json");
request.AddParameter("data", request.JsonSerializer.Serialize(issueToCreate));
request.RequestFormat = DataFormat.Json;
IRestResponse response = client.Execute(request);
我能得到什么回来是一个415的回应
Unsupported Media Type
注意:我也尝试了this post中提出的建议,但是这并没有解决问题。任何指导表示赞赏!
谢谢沃尔!对于任何发现这篇文章的人来说,因为它特别与JIRA有关,我还发现Atlassian的REST服务(也许这是全面的)是区分大小写的!在我的JiraIssue类中,我创建了诸如“Key”和“Summary”之类的属性,但它必须是“key”和“summary”...... doh! – gopherr
对于任何感兴趣的人,我已经在JIRA REST客户端和WPF应用程序[此处](https://bitbucket.org/grodgers/jiravu/overview)中实现了此RestSharp POST。 – gopherr