jira api を使用して課題に添付ファイルを追加しています
ドキュメントによると、私はいくつかのことを設定しました。
X-Atlassian-Token: nocheck のヘッダーをリクエストと共に送信します。
添付ファイルを含む multipart/form-data パラメータの名前は「file」でなければなりません。
リソースはマルチパート投稿を期待しています。
コードを実行すると、内部サーバー エラーが発生します。
私のコードは次のとおりです
string postUrl = "http://localhost:8080/rest/api/latest/issue/TES-99/attachments";
System.Net.Http.HttpClient client = new System.Net.Http.HttpClient();
client.DefaultRequestHeaders.Add("X-Atlassian-Token", "nocheck");
client.BaseAddress = new System.Uri(postUrl);
byte[] cred = UTF8Encoding.UTF8.GetBytes(credentials);
client.DefaultRequestHeaders.Authorization = new System.Net.Http.Headers.AuthenticationHeaderValue("Basic", Convert.ToBase64String(cred));
var content = new MultipartFormDataContent();
var values = new[]
{
new KeyValuePair<string, string>("file", "e:\\z.txt")
};
foreach (var keyValuePair in values)
{
content.Add(new StringContent(keyValuePair.Value), keyValuePair.Key);
}
var result = client.PostAsync(postUrl, content).Result;
私が間違っているところを教えてください