It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

Jira API - Insight object customfield

Hi!

I'm using REST API to create issues in Jira. However, I was not able to fill a "Insight object" custom field. I'm getting "data was not an array" and "expected Object" error when passing values to these fields:

image.png

The code:

request.post(myhost.com, {
'auth': {
'user': 'user',
'pass': 'pass',
'sendImmediately': true
},
json: {
fields: {
project : {
key : "test"
},
summary: createDescription[i],
description : createInformation[i],
customfield_12300 : createNumber[i],
customfield_10218 : "SERVICE-61413",
customfield_10225 : "SERVICE-61481",
customfield_10226 : "SERVICE-61574",
issuetype : {
name: "test"
}
}
}
}

 I was trying to fix "data was not an array" error by passing values as

customfield_10218 : ["SERVICE-61413"],
customfield_10225 : ["SERVICE-61481"],
customfield_10226 : ["SERVICE-61574"],

but this resulted in "expected Object" error:

image.png

Also I've tried to pass these values not as object key but object name, but this didn't work either.

How do I pass values to Insight object customfield correctly?

2 answers

1 accepted

0 votes
Answer accepted

Hi Gleb,

We will paste the answer here for everyone to benefit from the information ;)

The correct format to send in the JSON payload would be

"customfield_10225" : [{"key" : "SERVICE-1"}]

Cheers!

Nader

Mindville team

Glad it was sorted. It will be useful for others, definitely.

0 votes

Hi @Gleb Kartashov 

What is the type of "Insight" custom object? 

One trick is to set this value via UI manually for one Issue and retrieve it via "Get Issue" and see what format the value comes back as. Then you can use the same format to send back for new issues.

Thanks for responding! I've tried to create a test issue and get it from API, this is what Insight objects look like:

image.pngTried to pass this exact values to create issue script but still got "expected Object" error

So did some experiments with JS code and turned out this format

customfield_10218 : [{0:"SERVICE-1"}]

makes it possible to create an issue. But in Jira this field is empty and if I try to get newly created issues from API the fields are empty also.

Suggest an answer

Log in or Sign up to answer
Community showcase
Posted in Jira Service Desk

Tell us how you've implemented Change Management

Hello Community 👋, I'm a product manager at Atlassian, looking at improving change management capabilities across our products. In particular, we're looking at bridging the gap between Dev & ...

1,784 views 10 17
Join discussion

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you