我正在尝试使用RestSharp进行POST请求,在JIRA中创建问题,我所拥有的是一个使用cURL的示例。我对两者都不熟悉,不知道哪里出了问题。
这是cURL中给出的示例:
这里是他们的示例数据:
我收到的是一个415响应。
注意:我也尝试了在此帖子中提到的方法,但这并没有解决问题。感谢任何指导!
这是cURL中给出的示例:
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
注意:我也尝试了在此帖子中提到的方法,但这并没有解决问题。感谢任何指导!