Short guide for integrating Jira Cloud With ServiceNow using iHub Cloud
Create App in ServiceNow
Decide on authentication type, select OAuth2 or JWT.
JWT
Setup Credentials in iHub Cloud
OAuth2
Navigate to Credentials
Click Add Credentials
Select OAuth2
Click Save
Select Grant type: Resource Owner Password Credentials Grant
Enter the following fields;
Authorization Url: <instance-url>/oauth_auth.do
Username: the integration user
Password: the integration password
Client Id: from Create App in ServiceNow step
Client Secret: from Create App in ServiceNow step
Scope: leave blank
Click Save
Copy the callback URL on the credentials page and go back to the ServiceNow app and paste in the callback and save that.
Click “Click here to Authorize” button
Send Issue data to ServiceNow from Jira Cloud
Create a Incident
Create a new Integration
Set a trigger like Issue Created and provide a simple JQL
Create an Action
Select POST as method
Enter url to your instance example https://dev262540.service-now.com/api/now/v1/table/incident
Select the Authentication created in the above step
Enter the Body
{ "short_description": "{{issue.summary}}", "description": "{{{toJSON issue.fields.description}}", "urgency": 2 }
Saving ServiceNow incident number on the ticket
Create an Action, select template Update Issue ( this for convenience you may create a empty action and configure it if you like)
Enter a name, like Update issue
Select the custom field that you like to put the incident number into, enter the value "{{result.number}}"
Upload attachments to Incident
ServiceNow attachment API can only receive one file at the time, hence we will iterate over the unsent attachments and send one at the time.
Create an Action
Select the create incident as parent
Select POST as method
Enter url to your instance example https://dev262540.service-now.com/api/now/attachment/upload
Select the Authentication created in the above step
Click Condition, this to prevent this action to be triggered if there is no attachment added and prevent already sent files to be sent.
Define the Condition. Fill in the following details:
JSON Path: Enter
$.attachments.unsentFile.length
Operand: Select "Greater than"
Value: 0
Click Advanced tab and enter the iteration path
$.issue.fields.attachment
to make this action run onetime per attachment found on the ticket.Enter the Body
{ "table_sys_id":"{{result.sys_id}}", "table_name":"Incident", "file":"{{attachments.unsentFile}}" }