In this code when i create webhook for issue then it gets triggered when issue is updated but when i create child issues in it webhook doesn't trigger. This an OAuth2.0 app is there some other way?
Hi @Username
By including the jira:subtask_created event and modifying the JQL filter to include child issues, you can ensure that the webhook triggers when sub-tasks are created under the specified parent issue.
This approach should work as expected and cover your requirements for monitoring child issues.
Ensure Jira API token and event names are accurate
python
import requests
import json
# Create JQL filter specific to the issue
project_key = "YOUR_PROJECT_KEY"
issue_key = "YOUR_ISSUE_KEY"
jql_filter = f'project = "{project_key}" AND (issuekey = "{issue_key}" OR parent = "{issue_key}")'
webhook_url = "YOUR_WEBHOOK_URL"
# Prepare the payload
data = {
"url": webhook_url,
"webhooks": [
{
"events": [
"jira:issue_created",
"jira:issue_updated",
"jira:subtask_created" # Listen for sub-task creation
],
"jqlFilter": jql_filter,
"enabled": True
}
]
}
# Authentication headers (assuming OAuth 2.0 token)
headers = {
"Authorization": f"Bearer YOUR_OAUTH_TOKEN",
"Content-Type": "application/json",
"Accept": "application/json"
}
# Jira API endpoint for creating webhooks
jira_webhook_url = f"https://your-jira-instance.atlassian.net/rest/api/3/webhook"
# Send the POST request to create the webhook
response = requests.post(jira_webhook_url, headers=headers, data=json.dumps(data))
if response.status_code == 201:
print("Webhook created successfully.")
else:
print(f"Failed to create webhook. Status code: {response.status_code}")
print(response.text)
Hope this helps - Happy to help further!!
Thank you very much and have a great one!
Warm regards
because of jql limitation in jira API I am unable to use parent clause and subtask_created event because both of them gives error stating parent clause unsupported and invalid subtask_created event
this is the full code ->
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thanks for insight,
To overcome the limitations of Jira's JQL and webhook events, you can utilize Jira Automation to monitor subtask creation and trigger external webhooks.
This can be achieved by creating an automation rule in Jira, which involves setting a trigger for issue creation, a condition to specify that the issue type is a subtask, and an action to call your external webhook.
Otherwise, you can leverage Jira's Automation API to dynamically create these rules, particularly useful when dealing with multiple parent issues.
Regards
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.