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?
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
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.