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

How to get the REST API structure for a custom field?

Mark May 24, 2018

I am preparing a PowerShell script to generate an issue. The error I got is:

"errorMessages":[],"errors":{"Application":"data was not an array"}}

The "Application" field (customfield_11040) is a dropdown menu allowing multiple selection. The values are "HR system","IT system","Purchasing system" etc.

My Powershell compose the json body like below:

$messageBody = @{
fields = @{
project = @{
key = "IT"
}
summary = "test create issue"
description = "Creating of an issue using project keys and issue type names using the REST API"
issuetype = @{
name = "Bug"
}
customfield_11043 = @{
name="test"
}

#application field
customfield_11040 = @{
Application="HR system"
}
}
}

Please advice how can I check the structure of customfield_11040?

2 answers

1 accepted

0 votes
Answer accepted
Alexey Matveev Community Leader May 24, 2018 • edited

Hello,

You can find an answer here:

https://developer.atlassian.com/server/jira/platform/jira-rest-api-examples/#creating-an-issue-examples

There are examples for all custom field types.

Mark May 24, 2018

How can I get customfield_11040's field type?

The error returned is weird

":{"Application":"data was not an array"}}

it is not returning :

":{"customfield_11040":"data was not an array"}}

 

Also, I tried to input the data as "array" . Is the error trying to tell me I should not use Array?

Alexey Matveev Community Leader May 24, 2018

It means that you did not provide an array. I gave an example, can you provide here your final json?

Mark May 27, 2018 • edited

Here is part of JSON I "post" to JIRA:

"description":  "Creating of an issue using project keys and issue type names using the REST API",
"customfield_11040":  {
                          "id":  "11521"
                      },

 

and error returned:

{"errorMessages":[],"errors":{"Application":"data was not an array"}}

 

Then I have another try with follow JSON:

 

 

"customfield_11040":  "[ {\"value\": \"EPM\" }, {\"value\": \"ADM\" }] ",

 

and error returned exactly the same.

Alexey Matveev Community Leader May 28, 2018

Your JSON should be like this:

{"fields":{"customfield_11040"[ {"value": "EPM" }, {"value": "ADM" }]}}
Mark May 28, 2018

Thanks Alexey. I missed the bracket before. I can now POST successfully.

0 votes
Mark May 24, 2018

I print out the JSON structure for my POST:

 

{
"fields": {
"issuetype": {
"name": "Bug"
},
"description": "Creating of an issue using project keys and issue type names using the REST API",
"customfield_11040": {
"application": "HR system"
},
"customfield_11043": {
"name": "test"
},
"summary": "test create issue",
"project": {
"key": "TEST"
}
}
}

Suggest an answer

Log in or Sign up to answer
This widget could not be displayed.
This widget could not be displayed.
Community showcase
Published in Next-gen

Introducing subtasks for breaking down work in next-gen projects

Teams break work down in order to help simplify complex tasks. This is often done iteratively, with tasks being broken down into smaller tasks and so on until the work is accurately captured in well-...

1,095 views 13 15
Read article

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