I’m working on a Power Pages project that requires a Jira service desk task to be created for each portal submission. Out of the box, Jira provides a simple connector to create tasks and requests, but the connect falls short of handling field types other than simple text. This means choice, checkbox, and dropdown fields are not available. This only leaves a couple of options, and I opted to use a simple HTTP action to create the tasks.
Basic overview of what I’ll be creating:
Flow that’s triggered by a dataverse row creation
Create a Jira task and populate metadata
Attach a file to the Jira task
Jira fields and types:
Issue Type – Choice
Request Type – Choice
Tortilla – Choice
Meat – Choice
Veggies – Checkbox multi-select
Number of Tacos – Number
Pickup Date Time – Date and Time
Summary – Text
Attachment – Attachment
Interfacing with the Jira API requires knowing a little about the fields you’ll be updating and the project and issue type you want to use. If you haven’t created one already, you need a Jira API token to work with the API.
Request type:
Go to Project Settings, then look at the URL and copy the value after pid=
https://taco.atlassian.net/secure/project/EditProject!default.jspa?pid=10001
With the ID, you can query the service desk request-types endpoint
https://taco.atlassian.net/rest/servicedesk/1/servicedesk/request/10001/request-types
In the returned payload, note the portal key and key values; combine the two, and you have the request type value tr/9f7c4029-6d23-4cb1-bb8a-02d0050d944b
Project key:
The project key is available on the project settings page, listed under the name field.
Example: TACOS
Issue type:
For simplicity, I’m only dealing with one issue type, and I captured the issueType value using the request-types endpoint noted above.
Example: “issueType”: 10015
For the remaining field values, you can get them in one of two ways.
Create a new issue in the browser, then use the browser developer tools (F12 or Ctrl + Shift + I) to inspect each field’s HTML value.
The other option is to click the gear icon (top right), select Issues, click on Custom Fields, search for a field, click on it, click Edit detail, and then grab the ID value from the URL. Once the ID is captured, join it with customfield_, resulting in customfield_10073, which is the field’s internal value.
In this example, the summary issue type fields are the only ones that do not have a customfield_X naming convention. It might be possible that some system-generated fields have a different naming convention, but I’ll dig into that another day.
Column Display Name | Column Internal Name | Column Type |
Issue Type | issuetype | system |
Request Type | customfield_10010 | system |
Tortilla | customfield_10073 | Select List (single) |
Meat | customfield_10074 | Select List (single) |
Veggies | customfield_10075 | Checkboxes |
Number of Tacos | customfield_10076 | Number Field |
Pickup Date Time | customfield_10077 | Date Time Picker |
Summary | summary | system |
Endpoint URL:
https://taco.atlassian.net/rest/api/3/issue/
Headers: {“Content-Type”: “application/json”}
Authentication: Raw
Key: Basic aWhddsfadfafa..NOT…A…REAL…KEY..dafdfdafd=
Example payload:
{
"fields": {
"project": {
"key": "TACOS"
},
"customfield_10010": "tr/9f7c4029-6d23-4cb1-bb8a-02d0050d944b",
"summary": "Taco order summary",
"issuetype": {
"id": "10015"
},
"customfield_10073": {"value": "Flour"},
"customfield_10074": {"value": "Chicken"},
"customfield_10075": [{"value": "Pico"},{"value": "Grilled Veggies"}],
"customfield_10076": 2,
"customfield_10077":"2022-11-05T11:05:00.000+0000"
}
}
View of the task in Jira
How do you attach a file to a Jira task using Power Automate?
Attaching a file to a Jira task requires one more API call, and it’s simple!
Endpoint URL:
https://taco.atlassian.net/rest/api/3/issue/Key/attachments
Headers: {“X-Atlassian-Token”: “no-check”}
Authentication: Raw
Key: Basic aWhddsfadfafa..NOT…A…REAL…KEY..dafdfdafd=
Example payload:
{
"$content-type": "multipart/form-data",
"$multipart": [
{
"headers": {
"Content-Disposition": "form-data; name=\"file\"; filename=@{outputs('Get_file_properties')?['body/{FilenameWithExtension}']}"
},
"body": @{body('Get_file_content')}
}
]
}
Attachment
I’m getting a file from SharePoint and passing its contents to the API call for the attachment. The same thing works with Azure blob storage or grabbing a file from the dataverse. If you want to attach more than one file, create additional HTTP attachment calls.
Here’s a simple overview of the Flow:
Parse JSON schema:
{
"type": "object",
"properties": {
"id": {
"type": "string"
},
"key": {
"type": "string"
},
"self": {
"type": "string"
}
}
}
The Jira documentation is great, and the forums are active and helpful.
Hi!
Great document! I am also trying to add an/multiple attachment to a jira issue. I am using OneDrive and sharepoint but I do not really understand what to put in the fields in “get file properties”, “get file content” and for the “content” field in Parse JSON. Would you mind showing what you put in those fields?
It would be greatly appreciated.
The parse JSON is getting the key from the HTTP Create Jira Task action. The key is then used to form the HTTP URI for the attachment action. http://example/rest/api/3/issue/key
In the example, I’m using dataverse as the trigger source. From there, I’m getting the associated SharePoint doc properties, then file content.
Let me know if this helps or not.
Have you been able to do this and make the attachment visible to the customer via the customer portal?
Hey Marcus, I haven’t worked with the Customer Portal related to Atlassian. Their forum is active and valuable; someone there might have some insight into the issue if it’s not working. I got this working in Postman, then moved to Flow to iron out things.
Hi Its a great post and thanks for detail blog.
I am trying to implement the same thing, but somehow no luck. Every time i am getting error as “{“errorMessages”:[“You do not have permission to create issues in this project.”],”errors”:{}}”
Strange part i can create from UI.
Below is sample code , Kindly suggest what is wrong in it.
https://<>/rest/api/3/issue/
Body :
{
“fields”: {
“project”: {
“key”: “CADD”
},
“summary”: “Jira Integration summary-1”,
“description”: “Creating an issue via REST API”,
“issuetype”: {
“name”: “Bug”
}
}
}
Authentication using as Raw
You need an API key. The Jira API is unaware of the user running the Flow.
This info was included in the post:
you haven’t created one already, you need a Jira API token to work with the API.
Look at the post above for the link to create the key, then use it in your Flow.
Before I got my Flow working, I spent a lot of time in Postman trying to figure things out. You might start there.
Yes, I have tried the reference of blog but still i am getting the same error. Below is sample code.
I have created the API key and that key I have used as Value after selecting the Authentication method as Raw and value is
1 option: “Basic keyvalue”‘
1 option: “Keyvalue”‘
Kindly suggest on the part
@Pravin,
You need to set an header as Authorization with value as Basic followed by your key. I am assuming you are encrypting your key using the method specified by Atlassian.
@Ian,
Thanks for a great thread. It cleared all the doubts that I had.
I’d like to add that a list of field internal names and display names can be derived from this link:
https://taco.atlassian.net/rest/api/2/issue/TACOS-1?expand=names
where TACOS-1 is the ID of an existing task in your project.