Forums

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

Bulk Updating Issues via Jira API and CSV

Fariha Raza July 30, 2021

I'm currently trying to update many issues at once through powershell using a CSV. I import a CSV and then use a foreach loop, but I cannot get it to work. What would I need to include in the foreach loop since I am not creating any fields and just updating 1 column? 

3 answers

0 votes
Daniel Ebers
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
August 3, 2021

Hi @Fariha Raza

being unsure where you are stuck exactly it would be the best, like Claudio said, to share your code you use to query the REST API (just be sure to anonymize details like your site name and login details).

For a more general information you could look into the examples for editing issues via REST API on Jira Cloud:

There are several information available and inspiration how the calls could be made.

Regards,
Daniel

Fariha Raza August 4, 2021

Hi @Daniel Ebers 

So here I am importing my CSV with multiple issues (it has their unique issue id) and iterating through the file using a for each loop. The issue I am running into is if I am trying to update the summary and the CSV already has the updated version, how can I pass it along so it updates in Jira?

 

Import-Csv import.csv | ForEach-Object {
$issueid = $_.issueid
$project = $_.project
$issuetype = $_.issuetype
$summary = $_.summary
$reporter = $_.reporter

Write-Host "Issue will be updated in $($project), whose issueid is $($issueid), whose issutype is $($issuetype), whose summary is $($summary), whose reporter is $($reporter)."

$json = @"
{
"fields": {
"summary": $summary,
"description": "UPDATED"
}
}
"@


$params = @{
Uri = 'https://xxxxx.com/rest/api/2/issue/'
Headers = @{ Authorization = "Bearer $token" }
Method = 'PUT'
Body = $json
ContentType = "application/json"
}

Invoke-RestMethod @params

Daniel Ebers
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
August 9, 2021

If I understand you correctly the current challenge is to update existing issues, correct?
This is perfectly possible - when a few things are considered.

The issue I am running into is if I am trying to update the summary and the CSV already has the updated version, how can I pass it along so it updates in Jira?

You can refer to "Updating existing issues" on the following page: https://support.atlassian.com/jira-cloud-administration/docs/import-data-from-a-csv-file/

If it does not work it suggest the issue cannot be updated for whatever reason (could you double check via a manual CSV import and compare with the logs, please?), or, the code is not working as it should (I can't tell from here because not being familiar with PowerShell) or some other problem is existant which we did not consider yet.

One potential cause is probably to not mention the issue key explicitly (issue key from CSV / JSON in your example) when updating an issue - I seem to understand you are not providing it in the API call. This, according to documentation, is necessary, though.

Best bet is to test it step by step, manually via CSV import, then to try along.

0 votes
Bill Sheboy
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
August 2, 2021

Hi @Fariha Raza 

Have you tried to use only a CSV import to update the issues?  Please look here for information on setting up a CSV file to perform an update:

https://support.atlassian.com/jira-cloud-administration/docs/import-data-from-a-csv-file/

Best regards,
Bill

Fariha Raza August 2, 2021

Hi @Bill Sheboy 

I did try this way already, but I am trying to do it via the API route because it seemed like a better option for me.

Like Bill Sheboy likes this
0 votes
Claudio Gonzalez
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
July 30, 2021

Hi @Fariha Raza , 

Can you send the customfield type, Jira API and body. In some situations the unique problem is how to make the body of the Jira API. 

Fariha Raza August 2, 2021

Hi @Claudio Gonzalez 

I am not using any custom fields at the moment. I was able to create 2 dummy issues, but the updating, I am not sure what I would say in the script for it to understand that I just want to update it and not create. 

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
PRODUCT PLAN
FREE
TAGS
AUG Leaders

Atlassian Community Events