Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

A question about addAttachmensToIssue.

Di Wang September 15, 2011

I use the method of addAttachmentsToIssue in jira soap, but I am confused about the fourth parameters in the addAttachmentsToIssue($token,$issueKey, string[] filename, byte[][] attachments), no matter which data I pass to it, it will return the mistakes. this is my code:

$fPath = $_FILES['upload']["tmp_name"];

$fName = $_FILES['upload']["name"];

$fOpen = fopen($fPath,'rb');
$fByte = fread($fOpen,filesize($fPath));

$result = $client->call('createIssue',array($token, $issueInfo));

$issueKey=$result['key'];
$fileName=array();
$fileName[]=$fName;
$fileBytes=array();
$fileBytes[]=$fByte;
$attach=$client->call('addAttachmentsToIssue',array($token,$issueKey,$fileName,$fileBytes));
var_dump($attach);
exit;

the array returned is :

array
  'faultcode' => 
<small>string</small>
 'soapenv:Server.userException' (length=28)
  'faultstring' => 
<small>string</small>
 'org.xml.sax.SAXParseException: An invalid XML character (Unicode: 0x0) was found in the element content of the document.' (length=120)
  'detail' => 
    array
      'faultData' => 
        array
          'columnNumber' => 
<small>int</small>
 864
          'exception' => null
          'lineNumber' => 
<small>int</small>
 1
          'message' => 
<small>string</small>
 'An invalid XML character (Unicode: 0x0) was found in the element content of the document.' (length=89)
          'publicId' => null
          'systemId' => null
      'hostname' => 
<small>string</small>
 'jira.nyc' (length=8)

1 answer

0 votes
Bob Swift
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
September 15, 2011

Use addBase64EncodedAttachmentsToIssue and encode it with org.apache.axis.encoding.Base64.encode. There is code that does this in the addAttachment function here: https://bitbucket.org/bob_swift/jira-cli/src/6ef8b49e6268/src/main/java/org/swift/jira/cli/JiraClient.java

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events