user-1
(User 1)
August 23, 2023, 2:44pm
1
This topic was automatically generated from Slack. You can find the original thread here .
I want to create a custom jira integration. Something happens (trigger) and there should be an issue created in jira. ProjectId and IssueId should be dynamic. When entering this I get this (see screenshot). When I use the predefined values provided by Pipedream (I suppose they are retrieved by the Jira API) everything works. When entering this manually I use the same values (e.g. The value I get from pipedream for bug issues is 10004. When entering 10004 manually I get the error). Can anyone help?
user-1
(User 1)
August 23, 2023, 2:44pm
2
Hi Stefan, there might be some additional props under the hood that are using a different format for the value
of the prop.
Could you file this as a bug report here?
user-1
(User 1)
August 23, 2023, 2:44pm
3
This issue sounds very similar to the one mentioned above with the Airtable actions.
I would suggest using the JIRA API directly in a Node.js or HTTP Request action instead if you can.
user-1
(User 1)
August 23, 2023, 2:44pm
4
can you show me how to create a JIRA issue with a Node.js code step with a project ID and an Issue ID passed as props to the component?
user-1
(User 1)
August 23, 2023, 2:44pm
5
Sure! Here’s a Node.js code step that creates a JIRA issue using the JIRA API. You’ll need to pass the projectId
and issueTypeId
as props to the component: import { axios } from "@pipedream/platform"; export default defineComponent({ props: { jiraApiToken: { type: "string", label: "Jira API Token", secret: true, }, jiraEmail: { type: "string", label: "Jira Email", }, jiraDomain: { type: "string", label: "Jira Domain", }, projectId: { type: "string", label: "Project ID", }, issueTypeId: { type: "string", label: "Issue Type ID", }, summary: { type: "string", label: "Issue Summary", }, description: { type: "string", label: "Issue Description", optional: true, }, }, async run({ $ }) { const auth = { username: this.jiraEmail, password: this.jiraApiToken, }; const data = { fields: { project: { id: this.projectId, }, issuetype: { id: this.issueTypeId, }, summary: this.summary, description: this.description, }, }; const response = await axios($, { method: "POST", url: `https://${this.jiraDomain}/rest/api/3/issue`, auth, data, }); return response; }, });
Replace the placeholders with your JIRA API token, email, and domain. Make sure to fill in the projectId
, issueTypeId
, summary
, and description
(optional) props when using this component in your workflow.
user-1
(User 1)
August 23, 2023, 2:44pm
6
please use the JIRA app prop instead of passing an API key as a prop
user-1
(User 1)
August 23, 2023, 2:44pm
7
I understand, let’s modify the code to use the Jira app prop instead of passing the API key as a prop. Here’s the updated code: import { axios } from "@pipedream/platform"; export default defineComponent({ props: { jira: { type: "app", app: "jira", }, projectId: { type: "string", label: "Project ID", }, issueTypeId: { type: "string", label: "Issue Type ID", }, summary: { type: "string", label: "Issue Summary", }, description: { type: "string", label: "Issue Description", optional: true, }, }, async run({ $ }) { const auth = { username: this.jira.$auth.email, password: this.jira.$auth.api_token, }; const data = { fields: { project: { id: this.projectId, }, issuetype: { id: this.issueTypeId, }, summary: this.summary, description: this.description, }, }; const response = await axios($, { method: "POST", url: `https://${this.jira.$auth.domain}/rest/api/3/issue`, auth, data, }); return response; }, });
This code uses the Jira app prop and accesses the email, API token, and domain from the connected Jira account. Make sure to fill in the projectId
, issueTypeId
, summary
, and description
(optional) props when using this component in your workflow.
user-1
(User 1)
August 23, 2023, 2:44pm
8
will try. thanks for your help!