Cannot initialize a custom field (story points) using REST API, but can via Jira itself

PietroR May 28, 2021

Hi,

I will try to be brief and as accurate as possible:

  • I have an issue in a certain status where - using Jira UI - I can enter story points.
  • I need to be able to do that using REST API. However, that does not work for me and I get the following message: customfield cannot be set. It is not on the appropriate screen, or unknown.

But how come? For that very issue I can do that using Jira UI, so why not using REST API?

I tried (with the same results):

x["Story Points"] = "1";

and issue..CustomFields.Add("Story Points", "1" );

I noticed that even when that custom field is present until initialized with a first value, it is not returned in the list of customFields that REST api retrieves.

Thanks a lot

3 answers

0 votes
Kyle Webb
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
July 21, 2021

I ran into this issue with the C# SDK as well. What ended up working for me was editing the configuration for the 'Story Point' custom field. I had to switch it to 'Any issue type' to get it to work.

I thought maybe there was some weird thing where it didn't identify the 'Story' type correctly, but I switched it back to only having 'Epic' and 'Story' selected and it continued to work. It's almost like the 'Story' type from the initial type selection screen does not map to the same type that the edit screen maps to.

Hope this helps you out!

0 votes
Daniel Ebers
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.
June 5, 2021

Hi @PietroR

the error message "customfield cannot be set. It is not on the appropriate screen, or unknown." seems to be some kind of generic where it should not be - I met this one in a recent case where a authentication issue was involved. Hard to find and also some operations worked - which made things even more complicated... so ... adding to what David said previously:

6. Use a tool like Postman to check your ability to set the value of that field on that screen using its ID

I am wondering if:

  • you could do simplest queries successfully using the C# SDK approach
    • for example getting a list of projects
  • you succeed when doing a short check using Postman (and then to set the value) - basically this is exactly what David was asking

Please let Community members know about the outcome. Depending on what you see and experience somebody might be able to give more in-depth advice.

Cheers,
Daniel

0 votes
David Bakkers
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 29, 2021

Hello @PietroR

Search this forum for 'not on the appropriate screen, or unknown' for all the times this question has been answered, for all the different reasons why that error would be returned.

Also, your question said you tried "CustomFields.Add("Story Points", "1" );", which looks like some sort of programming language you're using. Your code refers to a field named "Story Points" but you must refer to fields by their ID, not their name, as the Jira Cloud REST API documentation explains. Since the Story Points field is a custom field, you would have to refer to it something like this "CustomFields.Add("customfield_123456", "1" );"

To know what the ID of the Story Points field is, as well as all the other fields, custom or not, query the Get fields endpoint.

PietroR May 29, 2021

Hi David,

I did search and read the other answers but I do not believe this is this case: the field certainly is allowed on the screen because I can do that (for the given story) in Jira UI, but I cannot use the REST API.

I use the C# SDK client.

When I refer to the custom field with its ID ("customfield_XXX), I get "Could not find ...."

Please suggest what I can do, this is really important for us.

PS: Using Jira server in our company.

EDIT: I believe I use it correctly when I call the method with "Story Points" as the fieldName, because then I get this error about the inappropriate screen and the right id (customfield_XXXX) is mentioned there, so apparently the mapping took place. But makes no sense - the issue in a status where I can set the story points in the UI, so there is nothing preventing doing it programmatically using the REST API.

David Bakkers
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 29, 2021

Hello @PietroR 

The error is giving you the right answer:

  1. Your reference to the field's ID is incorrect, which means you're using the wrong ID somehow.
  2. That field with that ID is not on the EDIT SCREEN, as it must be if you want to edit it.

 

Double check your work:

  1. Create a new issue.
  2. Select 'Edit' then look at the screen... do you see the Story Points field on that screen?
  3. If yes, the field is where it needs to be
  4. Use the REST API Get field endpoint to get the list of all the fields and their endpoints
  5. Find the Story Point field's ID
  6. Use a tool like Postman to check your ability to set the value of that field on that screen using its ID
  7. If yes, then your C# coding is incorrect. Re-read your code to see where you've gone wrong.
PietroR May 29, 2021

Hi David,

as I said, these cannot be the problems, details below:

  • As I said, when editing the issue in the Jira interface, the field is there.
  • The ID of this field is customfield_10106 (which is what I can see when inspecting retrieved data for another story where this field is set):image.png

 

  • The C# SDK takes "fieldName" as a parameter when adding or setting the custom field values, and I can confirm it does work with the name, not ID. All the other actions I work with (reading etc.) use the field name, not the ID - I think it is simply how the SDK is written. But I tried both (x is the reference to the object of the issue I work with):
    • x["customfield_10106"] = "1";
      x["Story Points"] = "1";
      x.CustomFields.Add("customfield_10106", "1" );
      x.CustomFields.Add("Story Points", "1");
      • When using the ID, I get a generic error that the field cannot be found, while when I use the field name, I can see it has been added to the object with the correct ID, but when it gets sent to the server, the message about the inappropriate screen is returned.
David Bakkers
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 30, 2021

Hi Pietro

Well, it sounds like you're very sure that the problem cannot be what I am suggesting it is, so I don't think I can be of any further help.

Have fun working it, and be sure to post the solution here once you've found it.

PietroR May 30, 2021

I wish it was, but from what I provided you can see for yourself that this is not the case - I checked and stated results of both your suggestions. It might be a problem in Atlassian C# SDK?

Also is it correct that custom fields with no value set are not returned in the list of custom fields for a given issue? E.g. for a newly created issue with no SPs set, this custom field is not listed unless it has been initialuzed with a value.

Justin Meyer November 4, 2023

I'm having the same problem.  Postman doesn't work.  Story points are visible in the sidebar. I'm using the rest API directly.  

Suggest an answer

Log in or Sign up to answer