Forums

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

Use PowerShell to update a custom field using version 3 of the API

Server Team
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
July 25, 2023

I can use the following curl command to update the custom field value.

curl --request PUT --url "https://<tenant_name>.atlassian.net/rest/api/3/issue/<issue_name>" --user "username@domain.com:<api_key>" --header "Accept: application/json" --header "Content-Type: application/json" --data "{""update"": {""customfield_10053"": [{""set"": ""123""}]}}"

But when I attempt to use the following PowerShell script it returns, "(400) Bad Request".

$headers = @{
Authorization = "Basic " + [Convert]::ToBase64String([Text.Encoding]::ASCII.GetBytes("$($username):$($apiToken)"))
Accept = "application/json"
"Content-Type" = "application/json"
}

$body = @{
update = @{
"customfield_10053" = @(
@{
set = "123"
}
)
}
} | ConvertTo-Json

 

Invoke-RestMethod -Uri "$jiraUrl/rest/api/3/issue/$issueKey" -Method Put -Headers $headers -Body $body

 

How can I get this to work?

0 answers

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
PRODUCT PLAN
STANDARD
PERMISSIONS LEVEL
Product Admin
TAGS
AUG Leaders

Atlassian Community Events