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

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

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.

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?

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

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.

Your JSON should be like this:

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

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

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
Community showcase
Published Mar 14, 2019 in Jira

Updates to jira.atlassian.com give you visibility into what's coming in Jira Server and Data Center

Hello, Community! My name is Gosia and I'm a Product Manager on Jira Server and Data Center here at Atlassian. Since 2002 when we launched our public issue tracker, jira.atlass...

629 views 1 15
Read article

Atlassian User Groups

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

Find a group

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

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you