<bdo id='fh1km'></bdo><ul id='fh1km'></ul>

<small id='fh1km'></small><noframes id='fh1km'>

<i id='fh1km'><tr id='fh1km'><dt id='fh1km'><q id='fh1km'><span id='fh1km'><b id='fh1km'><form id='fh1km'><ins id='fh1km'></ins><ul id='fh1km'></ul><sub id='fh1km'></sub></form><legend id='fh1km'></legend><bdo id='fh1km'><pre id='fh1km'><center id='fh1km'></center></pre></bdo></b><th id='fh1km'></th></span></q></dt></tr></i><div id='fh1km'><tfoot id='fh1km'></tfoot><dl id='fh1km'><fieldset id='fh1km'></fieldset></dl></div>
  • <tfoot id='fh1km'></tfoot>

      <legend id='fh1km'><style id='fh1km'><dir id='fh1km'><q id='fh1km'></q></dir></style></legend>

        将附件添加到 Jira 的 api

        Adding attachment to Jira#39;s api(将附件添加到 Jira 的 api)

          <tbody id='9uoYm'></tbody>

        <small id='9uoYm'></small><noframes id='9uoYm'>

        1. <tfoot id='9uoYm'></tfoot>
          • <bdo id='9uoYm'></bdo><ul id='9uoYm'></ul>

            1. <legend id='9uoYm'><style id='9uoYm'><dir id='9uoYm'><q id='9uoYm'></q></dir></style></legend>
                <i id='9uoYm'><tr id='9uoYm'><dt id='9uoYm'><q id='9uoYm'><span id='9uoYm'><b id='9uoYm'><form id='9uoYm'><ins id='9uoYm'></ins><ul id='9uoYm'></ul><sub id='9uoYm'></sub></form><legend id='9uoYm'></legend><bdo id='9uoYm'><pre id='9uoYm'><center id='9uoYm'></center></pre></bdo></b><th id='9uoYm'></th></span></q></dt></tr></i><div id='9uoYm'><tfoot id='9uoYm'></tfoot><dl id='9uoYm'><fieldset id='9uoYm'></fieldset></dl></div>

                  本文介绍了将附件添加到 Jira 的 api的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我正在尝试使用他们的 API 将文件附加到 Jira 案例.我在 Drupal 6 (PHP v.5.0) 中这样做.这是我的代码:

                  I am trying to attach a file to a Jira case, using their API. I am doing this in Drupal 6 (PHP v.5.0). Here is the code I have:

                  $ch = curl_init();
                  $header = array(
                    'Content-Type: multipart/form-data',
                     'X-Atlassian-Token: no-check'
                  );
                  $attachmentPath = $this->get_file_uploads();
                  //$attachmentPath comes out to be something like:
                  //http://localhost/mySite/web/system/files/my_folder/DSC_0344_3.JPG
                  
                  $data = array('file'=>"@". $attachmentPath, 'filename'=>'test.png');
                  $url= 'https://mysite.atlassian.net/rest/api/2/issue/20612/attachments/';
                  
                  curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
                  curl_setopt($ch, CURLOPT_VERBOSE, 1);
                  curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
                  curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
                  curl_setopt($ch, CURLOPT_HTTPHEADER, $this->get_jira_headers());
                  curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
                  curl_setopt($ch,  CURLOPT_POSTFIELDS ,$data);
                  curl_setopt($ch, CURLOPT_URL, $url);
                  curl_setopt($ch, CURLOPT_USERPWD, "myusername:mypassword");
                  
                  $result = curl_exec($ch);
                  $ch_error = curl_error($ch);
                  

                  问题是 $result 显示为 false,而 $ch_error 指出它无法打开文件.这个错误是否与 Drupal 或我如何将我的请求发送到 Jira 有关?顺便说一句,如果我使用绝对路径,就像这样:

                  The problem is that the $result comes out as false, and the $ch_error states that it couldn't open the file. Does this error have something to do with Drupal or something to do with how I'm sending my request to Jira? BTW, if I use an absolute path, though, like this:

                  $attachmentPath = 'C:wampwwwmySitewebsitesmySite.netfilesmy_folderDSC_0333.JPG';
                  

                  上传工作正常.

                  推荐答案

                  这应该适合你:

                  $data = array('file'=>"@". $attachmentPath . ';filename=test.png');
                  

                  这是 cURL PHP <5.2.10 的错误,您可以在 PHP 错误跟踪器中看到:https://bugs.php.net/bug.php?id=48962(在您看到的评论中,它已被修复)

                  This was a bug with cURL PHP <5.2.10, you can see this in the PHP bug tracker: https://bugs.php.net/bug.php?id=48962 (And in the comments you see, that it has been fixed)

                  如果你使用 PHP 5.5.0+,你可以使用这个:

                  And if you use PHP 5.5.0+ you can use this:

                  $cfile = new CURLFile($attachmentPath);
                  $cfile->setPostFilename('test.png');
                  $data = array('file'=>$cfile);
                  

                  您也可以在 JIRA 评论中看到这一点:JIRA 评论

                  You can also see this in a JIRA comment: JIRA Comment

                  另外我认为你想改变这个:

                  Also i think you want to change this:

                  curl_setopt($ch, CURLOPT_HTTPHEADER, $this->get_jira_headers());
                  

                  为此:

                  curl_setopt($ch, CURLOPT_HTTPHEADER, $header);
                  

                  这篇关于将附件添加到 Jira 的 api的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                  相关文档推荐

                  DeepL的翻译效果还是很强大的,如果我们要用php实现DeepL翻译调用,该怎么办呢?以下是代码示例,希望能够帮到需要的朋友。 在这里需要注意,这个DeepL的账户和api申请比较难,不支持中国大陆申请,需要拥有香港或者海外信用卡才行,没账号的话,目前某宝可以
                  PHP通过phpspreadsheet导入Excel日期,导入系统后,全部变为了4开头的几位数字,这是为什么呢?原因很简单,将Excel的时间设置问文本,我们就能看到该日期本来的数值,上图对应的数值为: 要怎么解决呢?进行数据转换就行,这里可以封装方法,或者用第三方的
                  mediatemple - can#39;t send email using codeigniter(mediatemple - 无法使用 codeigniter 发送电子邮件)
                  Laravel Gmail Configuration Error(Laravel Gmail 配置错误)
                  Problem with using PHPMailer for SMTP(将 PHPMailer 用于 SMTP 的问题)
                  Issue on how to setup SMTP using PHPMailer in GoDaddy server(关于如何在 GoDaddy 服务器中使用 PHPMailer 设置 SMTP 的问题)

                    <tbody id='p6pJZ'></tbody>
                • <small id='p6pJZ'></small><noframes id='p6pJZ'>

                  • <tfoot id='p6pJZ'></tfoot>

                    <i id='p6pJZ'><tr id='p6pJZ'><dt id='p6pJZ'><q id='p6pJZ'><span id='p6pJZ'><b id='p6pJZ'><form id='p6pJZ'><ins id='p6pJZ'></ins><ul id='p6pJZ'></ul><sub id='p6pJZ'></sub></form><legend id='p6pJZ'></legend><bdo id='p6pJZ'><pre id='p6pJZ'><center id='p6pJZ'></center></pre></bdo></b><th id='p6pJZ'></th></span></q></dt></tr></i><div id='p6pJZ'><tfoot id='p6pJZ'></tfoot><dl id='p6pJZ'><fieldset id='p6pJZ'></fieldset></dl></div>
                        <bdo id='p6pJZ'></bdo><ul id='p6pJZ'></ul>

                          1. <legend id='p6pJZ'><style id='p6pJZ'><dir id='p6pJZ'><q id='p6pJZ'></q></dir></style></legend>