Forums

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

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?

3 answers

1 accepted

0 votes
Answer accepted
Alexey Matveev
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
May 24, 2018

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
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
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

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
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
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
Yatish Madhav
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
July 13, 2020
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