Forums

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

Unable to retrieve context field options

Yellalingh Margonda October 15, 2020

Hi Team

I am trying to retrieve the custom field options using the https://developer.atlassian.com/cloud/jira/platform/rest/v3/api-group-issue-custom-field-options/#api-rest-api-3-customfield-fieldid-context-contextid-option-get i tried passing both custom field id and context id. I retrieved the context id using the https://developer.atlassian.com/cloud/jira/platform/rest/v3/api-group-issue-fields/#api-rest-api-3-field-fieldid-contexts-get. custom field options gives 404 error can some one please help me in retrieving the custom field options based on context

1 answer

1 accepted

2 votes
Answer accepted
Earl McCutcheon
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
October 19, 2020

Hello @Yellalingh Margonda ,

Thanks for reaching out and looking at this one it is a little confusing as the value formats for "fieldid" in the calls of the "field" endpoint compared to the call for the "customfield" endpoint are different and a little counterintuitive.

For obtaining the context id noted in the endpoint "GET /rest/api/3/field/{fieldId}/contexts"   you need to input the "fieldid" variable in the format "customfield_id" to differentiate between a system field (id only) vs custom fields (custom field + id)

An example of a custom field with ID = 10273 in my test instance would be as follows:

GET /rest/api/3/field/customfield_10273/contexts

the results come back as follows noting the context is "10420":

{
"maxResults": 20,
"startAt": 0,
"total": 1,
"isLast": true,
"values": [
{
"id": 10420,
"name": "Default Configuration Scheme for AAA_TEST_ elect List (single choice)",
"description": "Default configuration scheme generated by Jira",
"associatedIssueTypes": [
{
"self": "https://<BASE_URL>.atlassian.net/rest/api/3/issuetype/10108",
"id": "10108",
"description": "Track underlying causes of incidents. Created by Jira Service Desk.",
"iconUrl": "https://<BASE_URL>.atlassian.net/secure/viewavatar?size=medium&avatarId=10604&avatarType=issuetype",
"name": "Problem",
"subtask": false,
"avatarId": 10604
}
],
"associatedProjects": [],
"isAllProjects": true,
"isAllIssueTypes": false
}
]
}

Then in the secondary call "GET /rest/api/3/customField/{fieldId}/context/{contextId}/option"  as you are already doing a call against the custom field endpoint so there are not any standard fields as valid inputs so  the format for "fieldid" is going to only be formatted as the number as follows:

GET /rest/api/3/customField/10273/context/10420/option

And in my example would return as follows:

{
"maxResults": 100,
"startAt": 0,
"total": 8,
"isLast": true,
"values": [
{
"id": "10529",
"value": "1",
"disabled": false
},
{
"id": "10530",
"value": "2",
"disabled": false
},
{
"id": "10531",
"value": "3",
"disabled": false
},
{
"id": "10532",
"value": "4",
"disabled": false
},
{
"id": "10533",
"value": "5",
"disabled": false
},
{
"id": "10534",
"value": "6",
"disabled": false
},
{
"id": "10535",
"value": "7",
"disabled": false
},
{
"id": "10536",
"value": "8",
"disabled": false
}
]
}

Hope this helps, and let me know if you have any additional questions.

Regards,
Earl

Allen Culpepper
Contributor
February 25, 2021

I dont see that api available for Jira Server. Is there a way to do it in Server?

Yellalingh Margonda February 25, 2021


Hi Allen I currently need support on CA-1278615. 

Mauricio Heberle
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, 2022

it changed a bit:

 

rest/api/3/field/customfield_xxxxx/context/xxxxx/option

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
PRODUCT PLAN
STANDARD
TAGS
AUG Leaders

Atlassian Community Events