Receiving 400 Bad Request for GET to /rest/api/3/customField/{fieldId}/option

Greetings, I’m pulling my hair out over this one, I’ve been vetting a proof of concept using the Cloud REST API

Yesterday I was using POSTS to /rest/api/3/customField/{fieldId}/option to successfully create options, no problem. I wrote a powershell script to encapsulate the functionality and moved on to other areas of the api

Today, I am re-visiting custom fields, and without changing any code, no matter what I do I get a 400 bad request for POSTs and GETs to /rest/api/3/customField/{fieldId}/option.

I know it’s not an auth issue, because I can tamper with the token and I get a 401. Moreover, other api endpoints work. I don’t see any indication of any outages…which wouldn’t make sense since other areas of the API work, including service desk.

So, I generally figure stuff like this out on my own and don’t post much, but I feel like I’ve run out of options. Additionally, I know this route is deprecated this May, and I did try to use the context route but was getting 400s there as well.

Has any one run into something similar? It smells like something simple I’m missing, but I’m dumbing it down to just the GET, and that still yields a 400 everytime

Here’s what I’ve distilled down to to rule out all other factors (and again I know the auth is good because I can tweak the token and get a 400)

Invoke-WebRequest -Uri “https://mydomain.atlassian.com/rest/api/3/customField/13158/option” -Headers @{“AUTHORIZATION”=$authVal;“Content-Type”=“application/json”} -Method GET

So I humbly look to the community for any suggestions at this point with my hat in hand…

So, wanted to follow up, I created a new custom field and when I use it’s ID I can GET and POST…the original custom field still 400s…so for the life of me can’t explain why my original custom field is throwing 400s now, but I am just going to delete it and use the new field. Hope someone finds this helpful if ever they are in a similar situation

Hi @KevinBerquist,

Can you please try a new API for creating custom field options, which is:
https://developer.atlassian.com/cloud/jira/platform/rest/v3/api-group-issue-custom-field-options/#api-rest-api-3-field-fieldid-context-contextid-option-post ?
The one you are using right now is soon to be deprecated.

Greetingss, and thank you for your follow up,

So I wanted to try that route, however I was unable to create and retrieve a context id (which is required) using The Jira Cloud platform REST API (atlassian.com) and The Jira Cloud platform REST API (atlassian.com) respectively. Both would return 404 despite my best efforts. I confirmed the custom field id was correct during the process with the original route.

Any additional guidance would be greatly appreciated.

In order to create custom field options you have to create a custom field context first.
You can do it with this API:
https://developer.atlassian.com/cloud/jira/platform/rest/v3/api-group-issue-custom-field-contexts/#api-rest-api-3-field-fieldid-context-post

Then - you will get contextId which can then be applied to create custom field options:
https://developer.atlassian.com/cloud/jira/platform/rest/v3/api-group-issue-custom-field-options/#api-rest-api-3-field-fieldid-context-contextid-option-post

So please make sure that the context exists and belongs to the custom field you’re trying to manipulate.

Thank you, and indeed, I had tried to create contexts using those routes as well. However despite my best efforts I continue to receive 404s as indicated… I will continue my efforts as I suspect the documentation is correct, and there must be some thing mundane I am missing. Really appreciate your responses

Okay, as suspected, material oversight on my part, old route was using numeric id, I needed to use customfield_{numericid} with new routes. Mystery solved, thank you again for the responses.

Kind Regards