Ale
Ale

Reputation: 155

Insert comments in Jira with Talend

During my searching, I would like advice about how to insert a comment in Jira issue via Talend Open Studio.

Here is my job :

enter image description here

So, I am trying to insert comment via Talend. I use a tHttpRequest set like that :

enter image description here

uri is my string connection to get Jira account.

As it's a POST method, my header is Content-Type | application/json.

My post parameters are in a JSON file :

{
"fields": {
    "project": {
        "key": "TRL"
    },
    "summary": "A",
    "description": "B",
    "issuetype": {
        "name": "Task"
    },
    "labels": ["Webapp"],
    "reporter": {
        "name": "x.x"
    },
    "assignee": {
        "name": "x.x"
    }
},
"body": "TEST1",
"visibility": {
    "type": "role",
    "value": "Administrators"
}}

When I launch this job, the following error appears : enter image description here

As if the file of the response body was NULL, or maybe It's not the good manner to do the insert of the comment.

I clarify that with Insomnia(insomnia), the insertion of the comment works.

I try also the componant tRest but I don't succeed to link this one with tFileInputDelimited or tJIRAOutput.

Before to continue my work, I want to know if I am in the good direction ? Any clues ?

Thanks by advance,

Ale

Upvotes: 0

Views: 541

Answers (1)

borst.philipp
borst.philipp

Reputation: 52

I'd recommend using the tRest or tRestClient components. You can just send your JSON as "HTTP body" with these components.
On the JIRA side, you can get the necessary information here: https://developer.atlassian.com/jiradev/jira-apis

Assuming you're working with the on-premise JIRA, you'd use something like this:
URL: hostname + /rest/api/2/issue/{issueIdOrKey}/comment
HTTP Body:

{
    "body": "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Pellentesque eget venenatis elit. Duis eu justo eget augue iaculis fermentum. Sed semper quam laoreet nisi egestas at posuere augue semper.",
    "visibility": {
        "type": "role",
        "value": "Administrators"
    }
}

Don't forget about the Authentication

Upvotes: 1

Related Questions