Alex
Alex

Reputation: 1535

WSO2 ESB JIRA connector

in my use case i need to write a proxy in which i can dynamically build a jira issue catching the data from the request sent to the same proxy. In the payload of the request there is a Json object like this:

{"objId":"073456","user":"sysadmin","message":"asdas"}

From this json i want to build this jira "CreateIssue" statement:

<jira.createIssue> 
    <projectKey>MY PROJECT</projectKey> 
    <summary>Issue sent form user: USER related to object: OBJID </summary> 
    <description>MESSAGE</description> 
    <issueType>Bug</issueType> 
</jira.createIssue>

where USER, OBJID and MESSAGE are picked up from the json above. How can i do it?

Upvotes: 0

Views: 306

Answers (2)

HM.Rajjaz
HM.Rajjaz

Reputation: 389

You can use property mediator to picked up from the json above.

<property name="objId" expression="json-eval($.objId)"/>
<property name="user" expression="json-eval($.user)"/>
<property name="OBJID" expression="get-property('OBJID')"/>
<jira.createIssue> 
   <projectKey>MY PROJECT</projectKey> 
   <summary>Issue sent form user: {$ctx:user} related to object: {$ctx:objId} </summary> 
   <description>MESSAGE</description> 
   <issueType>Bug</issueType> 
</jira.createIssue>

Upvotes: 1

Jean-Michel
Jean-Michel

Reputation: 5946

You can use braces to specify dynamic values and xpath or JSON path (with "json-eval") to manipulate message payload, samples :

<summary>{concat('Issue sent form user: ', json-eval($.user), ' related to object: ', json-eval($.objId)}</summary>

<summary>{concat('Issue sent form user: ', //user/text(), ' related to object: ', //objId/text()}</summary>

see https://docs.wso2.com/display/ESB481/JSON+Support for more details

Upvotes: 0

Related Questions