Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in
Celebration

Earn badges and make progress

You're on your way to the next level! Join the Kudos program to earn points and save your progress.

Deleted user Avatar
Deleted user

Level 1: Seed

25 / 150 points

Next: Root

Avatar

1 badge earned

Collect

Participate in fun challenges

Challenges come and go, but your rewards stay with you. Do more to earn more!

Challenges
Coins

Gift kudos to your peers

What goes around comes around! Share the love by gifting kudos to your peers.

Recognition
Ribbon

Rise up in the ranks

Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!

Leaderboard

Come for the products,
stay for the community

The Atlassian Community can help you and your team get more value out of Atlassian products and practices.

Atlassian Community about banner
4,551,880
Community Members
 
Community Events
184
Community Groups

unable to update custom field

Hello,

I am trying to create a ticket using rest api. One of the fields that I include in payload is customfield

"schema"{"type": "any","custom": "com.riadalabs.jira.plugins.insight:rlabs-customfield-default-object","customId": 19509}

When i check the json of this field in existing ticket it shows me this 

"customfield_19509"["Team123 (PTCI-1549)"]
So my json is

"customfield_19509" = @("Team123 (PTCI-1549)") | ConvertTo-Json
but i am getting this error 
{"errorMessages":[],"errors":{"customfield_19509":"expected Object"}} 
When i send the object it says data was not array, please help

2 answers

1 accepted

0 votes
Answer accepted
Alex Koxaras _Relational_
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
Apr 23, 2023

Hi @Kenny Roostam and welcome to the community, 

The field you are trying to update is an asset field. As stated by your message, as well as gronthe asset rest api doc, the field should be an array. Please take a look at the documentation:

https://developer.atlassian.com/cloud/assetsapi/rest/api-group-assets/#api-group-assets

In addition, can you please paste here the request you are sending, as well as the payload?

Alex Koxaras _Relational_
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
Apr 23, 2023

@Kenny Roostam are on jira cloud or on premise?

@Alex Koxaras _Relational_ apologies, i was informed that its cloud but checking now, by going to /rest/api/2/serverInfo "deploymentType": "Server"  and version is v9.2

Alex Koxaras _Relational_
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
Apr 23, 2023

The check this link https://confluence.atlassian.com/servicemanagementserver/assets-rest-api-documentation-1044101761.html

Find the appropriate asset versions, as well as the right JSM version

Sorry @Alex Koxaras _Relational_ , so i can't set the values for assets fields using /rest/api/2/issue/ .I should use their own api right?

Alex Koxaras _Relational_
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
Apr 23, 2023

From the message you are getting, it seems that it works. However the data you are sending is not an object array.

I'm sending like this

$payLoad = @{
"fields" = @{
"customfield_19509" = @("Team123 (PTCI-1549)")
}} | ConvertTo-Json
but I get an error 
{"errorMessages":[],"errors":{"customfield_19509":"expected Object"}}

I'm sending like this
$payLoad = @{
"fields" = @{
"customfield_19509" = @(@{"value" = "Team123 (PTCI-1549)"})
}} | ConvertTo-Json

it creates the ticket however this field is not visible in ticket in browser. When i get the json of this ticket I see that its null "customfield_19509"null

However in another existing ticket json looks like this
"customfield_19509"["Team123 (PTCI-1549)"]
This ticket was created using UI
Do you know maybe how should I send this array properly?

I have tried with postman as well. When I send "customfield_19509"["Team123 (PTCI-1549)"
I get

 "errorMessages": [],
    "errors": {
        "customfield_19509""expected Object"
    }
and
When I send 
  "customfield_19509": [
      {
        "value""Team123  (PTCI-1549)"
      }
    ]
It goes thru and creates the ticket but customfield_19509: null and this field is not visible in ticket

hi @Alex Koxaras _Relational_  thanks for quick response 

$token = ""
$headers = @{
Authorization = "Bearer $token"
"Content-Type" = "application/json"
}
$payLoad = @{
"fields" = @{
"project" = @{
"key" = "SDSD"
}
"issuetype" = @{
"name" = "Change Request"
}
"summary" = "Test change request"
"description" = "test change request"
"assignee" = @{
"name" = "john.doe"
}
"customfield_13804" = @{
"value" = "Standard"
}
"customfield_19509" = @("Team123 (PTCI-1549)")
}
} | ConvertTo-Json -Depth 10

Invoke-RestMethod -Uri https://jirainstanceXXX.com/rest/api/2/issue/ -Method 'Post' -Headers $headers -Body $payLoad -ErrorAction Stop

Suggest an answer

Log in or Sign up to answer