Wiki

Clone wiki

projectspecificselectfield-public / REST API

Project Specific Select Field / REST API

Some of the administrative tasks can be done via REST API provided as part of Project Specific Select Field plugin starting with version 2.1 for custom fields of type Project Specific Select Field and Project Specific Multi Select Field. For custom fields of type Project Specific Select Field (simple) please use SQL API.

To create the corresponding URL for your JIRA instance please follow the following URL pattern, where {key} is project key, {id} is custom field ID. Use GET method to load.

http://{YOUR_JIRA_HOME_URL}/rest/projectspecificselectfield/1.0/customfield/{key}/{id}

An example would be the following.

http://localhost:2990/jira/rest/projectspecificselectfield/1.0/customfield/FCTA/customfield_10400

Getting custom fields

To get a list of all Project Specific Custom fields available for a certrain project use the following URL. Use GET method to load.

http://localhost:2990/jira/rest/projectspecificselectfield/1.0/customfield/FCTA

This returns a JSON or XML with list of Project Specific Field custom fields for the project.

[
  {"editable":false,"multiselect":false,"id":"customfield_10000","name":"Customer","type":"jira.plugin.projectspecificselectfield.jpssf:cftype"},
  {"editable":true,"multiselect":true,"id":"customfield_10400","name":"Development Team","type":"jira.plugin.projectspecificselectfield.jpssf:multicftype"},
  {"editable":true,"multiselect":false,"id":"customfield_10401","name":"Use Case","type":"jira.plugin.projectspecificselectfield.jpssf:singlecftype"}
]

Getting option values

To get all select option values available for a custom field for a project use the following URL pattern incl. project key and custom field ID. Use GET method to load.

http://localhost:2990/jira/rest/projectspecificselectfield/1.0/customfield/FCTA/customfield_10400

This returns a JSON or XML with list of options of this customfield.

[
  {"value":"Berlin","id":10104,"sequence":0,"disabled":false},
  {"value":"San Francisco","id":10105,"sequence":1,"disabled":false},
  {"value":"Praha","id":10103,"sequence":2,"disabled":false},
  {"value":"Singapore","id":10107,"sequence":3,"disabled":false},
  {"value":"Sydney","id":10200,"sequence":4,"disabled":false}
]

Adding option value

You can add a new select option to an existing custom field for project using project key and custom field ID. Use POST method to load.

http://localhost:2990/jira/rest/projectspecificselectfield/1.0/customfield/FCTA/customfield_10400

In the POST parameter when loading the URL add a JSON object representing the new option value.

{"value":"Barcelona","disabled":false}

As response you get a JSON object of the newly added option value now including its id.

{"value":"Barcelona","id":10400,"disabled":false}

Disabling option values

To disable a select option for a custom field for a project use the following URL pattern using project key and custom field ID. Please use PUT method.

http://localhost:2990/jira/rest/projectspecificselectfield/1.0/customfield/FCTA/customfield_10400/10400

In the PUT parameter when loading the URL add a JSON object representing the new option value.

{"id":10400,"disabled":true}

Updating option values

To update a select option for a custom field for a project use the following URL pattern, where {key} is project key, {id} is custom field ID and {value} is ID of the option. Please use PUT method.

http://localhost:2990/jira/rest/projectspecificselectfield/1.0/customfield/FCTA/customfield_10400/10400

In the PUT parameter when loading the URL add a JSON object representing the new option value.

{"id":10400,"value":"Madrid"}

Getting custom field contexts

To get a list of all contexts of a Project Specific Custom Field available use the following URL. Use GET method to load.

http://localhost:2990/jira/rest/projectspecificselectfield/1.0/context/customfield_10500

This returns a JSON or XML with list of all contexts defined for that Project Specific Field custom field.

[
  {
    "name":"Context 11000",
    "id":11000,
    "associatedprojets":[
      {"name":"Test Project","key":"FCTA"}
    ],
    "issuetypes":[
      {"name":"Epic","id":"10000"},
      {"name":"Story","id":"10001"}
    ]
  },
  {
    "name":"Context 10807",
    "id":10807,
    "associatedprojets":[
      {"name":"Test Project Three","key":"TPTH"},
      {"name":"Test Project Two","key":"TPT"}
    ],
    "issuetypes":[]
  },
  {
    "name":"Default Configuration Scheme for Product Segment",
    "id":10600,"associatedprojets":[],
    "issuetypes":[]
  }
]

If list of issue types is empty, this means that this context is valid for all issue types called "Global (all issues)".

If list of associated projects is empty, this means that this is the default context called global context "Global (all projects)" and is used for any project for which no specific context is defined called unassociated projects.

If there is no such a global context defined, then the custom field is only available for those projects explicitly named in a non-global context.

Adding new custom field context

Since version 3.0 of Project Specific Select Field plugin you can add a new custom field context to an existing custom field using project key and optionally issue type IDs and name. Use POST method to load.

http://localhost:2990/jira/rest/projectspecificselectfield/1.0/context/customfield_10500

In the POST parameter when loading the URL add a JSON object representing the new context. You can add name optionally, otherwise context name will be created automatically. If you leave issuetypes empty, then the context will be created globally valid for all issue types.

{"associatedprojets":["FCTA"],"issuetypes":["10000","10001"]}

As response you get a JSON object of the newly added context now including its id and project names and issue type names.

{
  "name":"Context 11000",
  "id":11000,
  "associatedprojets":[{"name":"Test Project","key":"FCTA"}],
  "issuetypes":[{"name":"Epic","id":"10000"},{"name":"Story","id":"10001"}]
}

Get list of unassociated projects of a custom field

To get a list of all unassociated projects of a custom field, call the following URL. Use GET method to load.

http://localhost:2990/jira/rest/projectspecificselectfield/1.0/context/unassociatedprojects/customfield_10500

The response will list all project for which no specific custom field context exist and could be created.

[
  {"name":"New Moon Rocket Project","key":"FCTB"},
  {"name":"Test Project","key":"FCTA"}
]

Updated