Web Services 向jira c#发布附件

gk7wooem  于 2022-11-24  发布在  C#
关注(0)|答案(1)|浏览(198)

我试图张贴一个附件到JIRA,但得到一个404 http错误。
我之前确实发表了一些评论,效果很好。
MY代码如下

string jsmlogin = "****";
            string jsmpass = "****";
   string _auth = string.Format("{0}:{1}", jsmlogin, jsmpass);
            string _enc = Convert.ToBase64String(Encoding.ASCII.GetBytes(_auth));
            string _cred = string.Format("{0} {1}", "Basic", _enc);
            string projKey = "DESK-1993";

            string postUrl = "https://******/rest/servicedeskapi/request/" + projKey + "/attachments";
            string jsmproxy = "http://********";
           
            
             var clientHandler = new HttpClientHandler();
            clientHandler.Proxy = new WebProxy(jsmproxy, true);
       
           HttpClient client = new HttpClient(clientHandler);

            client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Basic", _enc);
            client.DefaultRequestHeaders.Add("X-Atlassian-Token", "nocheck");
            client.DefaultRequestHeaders.Accept.Add(new System.Net.Http.Headers.MediaTypeWithQualityHeaderValue("application/json"));
            MultipartFormDataContent content = new MultipartFormDataContent();

           HttpContent fileContent = new ByteArrayContent(File.ReadAllBytes("z.txt.txt"));
           content.Add(fileContent, "file","z");
             var response = client.PostAsync(postUrl, content).Result;
laximzn5

laximzn51#

404错误提示I页面未找到抱歉,你所请求的页面不存在!
POST的URL应如下所示

http(s)://{base-url}/rest/api/{apiVersion or latest}/issue/{issue-key}/attachments

对我来说,你的/请求/部分看起来很奇怪,应该问题
这里是doc:附件

相关问题