What's the difference between (context) id and fieldContextId?

Hi there,

I made some experiments with custom field context configurations and noticed that the API

GET /rest/api/3/app/field/{fieldIdOrKey}/context/configuration

returns two ids

{
...
  "values": [
    {
      "id": "10000",
      "fieldContextId": "10010"
    },
...
}

Now I wonder, what’s the difference between those ids?

On most of my test instances both ids share the same value, but some instances do not. And this is a problem, when it comes to updating a context configuration using this

PUT /rest/api/3/app/field/{fieldIdOrKey}/context/configuration

Where the id in the body data, actually needs the value of fieldContextId - otherwise there’s an error.

Thanks in advance!
paul

Any idea what that is all about?

Hey, @ppasler,

Where the id in the body data, actually needs the value of fieldContextId - otherwise there’s an error.

That’s unexpected. In that API, id you PUT should be the same id you GET. Please report a bug if this isn’t the case.

@kkercz thanks for the response. It was not the same id (for PUT and GET) in my investigations.

I think the problem doesn’t occur all too often, as the id and the fieldContextId are the same on many instances. Could you explain what the fieldContextId is for?

I’ve also created a bugticket in the “Developer and Marketplace Support”. Is this the correct place?

id is the ID of the configuration, and fieldContextId is the ID of the field context (that you can interact with via these APIs: https://developer.atlassian.com/cloud/jira/platform/rest/v3/api-group-issue-custom-field-contexts/#api-group-issue-custom-field-contexts) associated with the configuration. You are right that in most cases they are the same, but not always, hence two different properties.

I’ve also created a bugticket in the “Developer and Marketplace Support”. Is this the correct place?

I would follow https://developer.atlassian.com/platform/forge/give-feedback/#forge-feedback:

For feedback on the Forge platform, create an issue in the Forge Jira project.

1 Like

@kkercz thanks again! I’ve also created a FRGE ticket: [FRGE-1280] - Ecosystem Jira

Hi @ppasler,
I’m trying to reproduce your problem in my environment - unfortunately, without success. Could you give me an error message you are getting and your instance url? It will help me with further investigation.

Best regards,
Łukasz

1 Like

Hi Łukasz,

thanks for checking! The problem only occurs if id and fieldContextId differ.

Here’s what I did

1. get context

GET /rest/api/3/field/customfield_<ID>/context

Response

{
...
    "values": [
        {
            "id": "10384",
            "name": "Default Configuration Scheme for a link field",
            "description": "Default configuration scheme generated by Jira",
            "isGlobalContext": true,
            "isAnyIssueType": true
        }
    ]
}

2. Save the new configuration in context

PUT /rest/api/3/app/field/customfield_<ID>/context/configuration

Payload

{
    "configurations": [
        {
            "id": "10384",
            "configuration": {
                "foo": "bar"
            }
        }
    ]
}

Result

{
    "errorMessages": [
        "Configurations with the following IDs do not exist for the given custom field: 10384."
    ],
    "errors": {}
}

Get all context configurations

/rest/api/3/app/field/customfield_<ID>/context/configuration

Result

{
...
  values: [{
    id: "10383",
    fieldContextId: "10384",
    configuration: {
      foo: "bar"
    }
  }]
}

I am still confused when to take id and when to take fieldContextId.

Hi @ppasler,

The GET /rest/api/3/field/customfield_<ID>/context returns the ID that is fieldContextId. Then, you are trying to use this fieldContextId to save the new configuration in context. As you are using an incorrect ID (it should be a configuration ID), the API returns an error and works as expected.

You can later see in your request to GET /rest/api/3/app/field/customfield_<ID>/context/configuration that the configuration id is indeed 10383.

Another problem I can see here is that you are trying to create a new configuration using this API. Unfortunately, currently, it is not possible with this method. The PUT /rest/api/3/app/field/{fieldIdOrKey}/context/configuration updates only existing configurations.

We are going to extend this API and also allow the creation of a new configuration. I cannot commit to a date, but we will inform you when it’s ready within this thread.

Best regards,
Łukasz

Hi @ljarzabek,

thanks for the detailed answer.
I am not trying to create a new configuration, but update it. As I apparently using the wrong id it fails to do so. I will try to use the right one.

Cheers,
paul