Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

How to Create ticket from service desk to service desk using webhooks?

Jakeer November 12, 2023

Hello Team,

How can we create a ticket from one JSM Instance to another JSM instance using Webhooks?

Any quick suggestions will be more helpful?

Thanks,

1 answer

1 accepted

2 votes
Answer accepted
Jehan Bhathena
Community Champion
November 13, 2023

Hey @Jakeer ,

You can use Jira Automation if you'd like to achieve this with minimum effort.

If the JSM project is on the same site, then you can use the "Create Issue" Action and pass the trigger issues data via the action.

If it's in a different site, then Jira API should be the approach I'd take. You can use the create Issue API and pass all the info in the body from the original issues content.

There are some free plugins available in the market place too that let you achieve issues creation without having to pay extra for it.

Do let us know if this helps, if I may have misunderstood the requirements please feel free to reply back to this thread.

If this thread helps please mark this as Accepted for more visibility to the other community members

Jakeer November 13, 2023

Hi @Jehan Bhathena

Thanks for the answer.

Can you please provide me the Automation rule for both same site and different. Even I have tried through automation rule getting errors.

Thanks,

Jakeer November 14, 2023

Hello @Jehan Bhathena

"If it's in a different site, then Jira API should be the approach I'd take. You can use the create Issue API and pass all the info in the body from the original issues content".

Can you please provide me the automation for the above one.

Quick reply will be more helpful.

Thanks in advance,

Jehan Bhathena
Community Champion
November 16, 2023
Jakeer November 17, 2023

Hi @Jehan Bhathena

Thanks for the Automation rule.

When I tried the same way, I am getting below errors. Which format do we specify a key, I have tried adding {{issue.key}} at the end of the URL Was still getting 404 Error.

Please help me on this.

1W.png2A.png

Jehan Bhathena
Community Champion
November 17, 2023

Hey @Jakeer ,

I tested this at my end and it seems that you will have to use the "Custom Data" instead.

To get the data required to pass in the custom data you can use this API : https://developer.atlassian.com/cloud/jira/platform/rest/v3/api-group-issues/#api-rest-api-3-issue-createmeta-get. Eg. https://<sitename>atlassian.net/rest/api/3/issue/createmeta?projectKeys=<projectKey>&expand=projects.issuetypes.fields .

The output from the above API can be used identify the fields and parameters needed for issue creation, you can then pass the formatted values in the Custom Data.

Adding a simple JSON that works for my CREATE issues screen where I have no Mandatory field: 

{

    "fields": {

        "summary": "Testing 123 - Push to Jira",

        "reporter": {

            "id": "<reporterUID>"

        },

        "project": {

            "id": "10000"

        },

        "issuetype": {

            "id": "10000"

        },

        "description": {

            "version": 1,

            "type": "doc",

            "content": [

                {

                    "type": "paragraph",

                    "content": [

                        {

                            "type": "text",

                            "text": "Testing dummy input"

                        }

                    ]

                }

            ]

        }

    }

}
Jakeer November 20, 2023

Hi @Jehan Bhathena

I have tried the same way you mentioned, but unfortunately, I am getting the errors.

Attaching the Automation Rule screenshot.

Thanks,Send webhook.png

Jehan Bhathena
Community Champion
November 20, 2023

Hi @Jakeer ,

The createmeta API call that you're using seems to have some issue.

I will recommend the below algo for the automation that you're creating:

  • TRIGGER: Based on when you want the issue to get replicated
  • CONDITION: Filter only the issue/s that you need
  • ACTION: LookUpIssues that you need to pass to the conditional loop
  • Advanced FOR, where the above issues need to be piped
    • Log issue key to verify if the correct key is used
    • WebRequest

Adding the body of the webrequest:

{
"fields": {
"summary": "Testing 123 - Push to Jira",
"reporter": {
"id": "{{issue.reporter.accountId}}"
},
"project": {
"id": "{{issue.project.id}}"
},
"issuetype": {
"id": "{{issue.issueType.id}}"
},
"description": {
"version": 1,
"type": "doc",
"content": [
{
"type": "paragraph",
"content": [
{
"type": "text",
"text": "{{#jsonEncode}}{{issue.description}}{{/}}{{issue.description.jsonEncode}}"
}
]
}
]
}
}
}

 

 image.png

To verify if the webRequest works you need to use the below validator:

image.png

I would recommend you go thru the smart values documentation here to get a better grasp on the Automation and what it can provide. https://support.atlassian.com/cloud-automation/docs/smart-values-in-jira-automation/

I cannot share a export of the automation at my end since it has content that can identify my site's UUID.

Jira also offers a great set of templates https://www.atlassian.com/software/jira/automation-template-library, you can use these to practice the automations too.

Hope this helps.

Jakeer November 21, 2023

Hai @Jehan Bhathena

Thank you so much for your help.

But unfortunately, I am getting error although I followed all the steps you have provided to me.

ThanksError.png

Jehan Bhathena
Community Champion
November 21, 2023

Hey @Jakeer ,

The user whose token you've used here doesn't seem to have Create Issue permissions. Can you verify if that can be changed and then retry?

Jakeer November 21, 2023

Hi @Jehan Bhathena

FYI, Both the instances belong to me, and I am having all the access and Create Issue Permission in both the instances.

AttachingPermission.png you the permission level screenshot with you

Thanks,

Jehan Bhathena
Community Champion
November 21, 2023

Hey @Jakeer ,

The POST request needs a Auth token, this token (to which ever user it belong) doesn't have access to create an issue. If you created a token previously I'd suggest creating a new one and retrying.

The above error is for permissions and more details can be found here: https://community.atlassian.com/t5/Jira-questions/quot-errorMessages-quot-quot-You-do-not-have-permission-to/qaq-p/2007900 

PS: Google search the error and you'll come across the same solution of checking the permissions.

Would recommend you check this on some tool like POSTMAN or curl to verify everything works and then move towards Jira Automation since it's easier to debug on API tools. :-)

Jakeer November 27, 2023

Hello @Jehan Bhathena

Thank you so much for your help and assistance.

Like Jehan Bhathena likes this

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events