Come for the products,
stay for the community

The Atlassian Community can help you and your team get more value out of Atlassian products and practices.

Atlassian Community about banner
4,256,586
Community Members
 
Community Events
164
Community Groups

jira add attachment api returns empty array with status code 200

Edited

Hi,

 

I am using wso2 ESB for Integrating one of my internal application with my JIRA instance

There is a feature - adding attachments to an issue in Jira. My internal application would send the filename and value(bytearray) in a json format. I will take that json, send it from my wso2 ESB to Jira to add the attachment.  when i am passing the bytearray and filename, it returns 200 status code but with empty array. Please find the below code. Can anyone has come across this kind of issue and help me. Thank you. 

 

<resource methods="POST" uri-template="/addAttachments/issues?issueKey={value}">
<inSequence>
<log level="custom">
<property name="message" value=">>>> Inside addAttachments API"/>
</log>
<property expression="get-property('query.param.issueKey')" name="uri.var.issueKey" scope="default" type="STRING"/>
<property expression="wso2:vault-lookup('Jira.Username')" name="Jira.Username" scope="default" type="STRING"/>
<property expression="wso2:vault-lookup('Jira.Password')" name="Jira.Password" scope="default" type="STRING"/>
<property expression="fn:concat(get-property('Jira.Username'),':',get-property('Jira.Password'))" name="JiraCredentials" scope="default" type="STRING"/>
<property expression="fn:concat('Basic ', base64Encode(get-property('JiraCredentials')))" name="Authorization" scope="transport" type="STRING" xmlns:ns="http://org.apache.synapse/xsd"/>
<header name="X-Atlassian-Token" scope="transport" value="nocheck"/>
<log level="custom">
<property expression="json-eval($)" name="inputpayloadFromPostman"/>
</log>
<payloadFactory media-type="xml">
<format>
<file>
<value>$1</value>
<options>
<filename>$2</filename>
<contentType>text/plain</contentType>
</options>
</file>
</format>
<args>
<arg evaluator="xml" expression="//value"/>
<arg evaluator="xml" expression="//filename"/>
</args>
</payloadFactory>
<log level="custom">
<property expression="json-eval($)" name="payloadfactory"/>
</log>
<property name="messageType" scope="axis2" type="STRING" value="multipart/form-data"/>
<property name="boundary" scope="default" type="STRING" value="----1234456----"/>
<header expression="fn:concat('multipart/form-data; boundary=',get-property('boundary'))" name="Content-Type" scope="transport"/>
<call>
<endpoint>
<http method="post" uri-template="https://xyx.atlassian.net/rest/api/2/issue/{uri.var.issueKey}/attachments">
<suspendOnFailure>
<initialDuration>-1</initialDuration>
<progressionFactor>1</progressionFactor>
</suspendOnFailure>
<markForSuspension>
<retriesBeforeSuspension>0</retriesBeforeSuspension>
</markForSuspension>
</http>
</endpoint>
</call>
<property expression="$axis2:HTTP_SC" name="HTTP_SC" scope="axis2" type="STRING"/>
<respond/>
</inSequence>
<outSequence/>
<faultSequence/>
</resource>

post.PNG

 

I have tried using Jira connector also, i t gives the same response.

 

 

 

2 answers

Hi,

You should set file's key = "file"

KEY           VALUE

file             testattach.txt

 

.

I am also getting the same error, I have changed file key even than the error is same can anyone help?

Suggest an answer

Log in or Sign up to answer
TAGS

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you