Create a user and find a user
Create User
To create a user in Jira make an Action that
Method: POST URL: Â {{baseUrl}}/rest/api/2/user
Body:
{
"name": "charlie",
"password": "abracadabra",
"emailAddress": "charlie@atlassian.com",
"displayName": "Charlie of Atlassian",
"applicationKeys": [
"jira-core"
]
}
Response:
{
"self": "http://www.example.com/jirahttp://www.example.com/jira/rest/api/2/user/charlie",
"key": "charlie",
"name": "charlie",
"emailAddress": "charlie@atlassian.com",
"displayName": "Charlie of Atlassian"
}
Find user
Method: GET URL: {{baseUrl}}/rest/api/2/user/search?username={{userName}}&includeInactive
Returns a list of users, if exact match the list should be 1 item in the array.
Â
Create a user and set that as reporter of a new issue
note indentation to visualise parent child of action levels. eg. 1,a,i
Action: Find user (use above GET request)
Action: Create User if not existing (use the create user example above)
Click on the Triggers & Conditions tab and select Parent, add the
JSON path: $[0]
Operand: !~
Value: name
This will tell iHub to execute only if there is no name parameter in the response from the parent.Action: Create Issue after user creation
in the body section add{ "fields": { "project": { "id": "10000" }, "summary": "something's wrong", "issuetype": { "id": "10000" }, "assignee": { "name": "homer" }, "reporter": { "name": "{{name}}" } } }
{{name}} variable comes from the parent response
Action: Create Issue if user exist
b1) In the json path add a variable:
Variable Name: name
JOSN Path: $[0].name
b2) Click on the Triggers & Conditions tab and select Parent, add the
JSON path: $[0]
Operand: ~
Value: name
in the body section add{{name}} variable comes from the parent response
Â
Â
Â
Ref doc:
https://docs.atlassian.com/software/jira/docs/api/REST/9.2.0/#api/2/user-findUsers