JIRA REST API for Atlassian Connect: how to create options for multi-select customfields? (NOT setting an individual issue's customfield value)

665 views
Skip to first unread message

Frank Polscheit

unread,
Feb 28, 2014, 3:31:02 PM2/28/14
to atlassian-...@googlegroups.com
Currently, you can create a new customfield using the JIRA REST API of all system field types.
Having created a multi-select customfield, how can I configure the choosable options using JIRA's REST API?
For Atlassian-Connect, it is not possible to write my own REST-addon to provide this missing feature by JAVA and plugin/2 as this cannot be installed within onDemand-instances.

Matt Quail

unread,
Mar 2, 2014, 5:41:08 PM3/2/14
to atlassian-...@googlegroups.com
Frank,

Just to collect a little more information: how are you creating/adding the custom field at the moment?

There is currently no REST endpoint under /rest/api/ for setting custom field options.

=Matt



--
You received this message because you are subscribed to the Google Groups "Atlassian Connect Dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to atlassian-connec...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Frank Polscheit

unread,
Mar 3, 2014, 4:38:32 PM3/3/14
to atlassian-...@googlegroups.com

Hi Matt,


I am using the following Javascript to create a new multi-select customfield within JIRA:


function addCustomfield(name, desc, type, searchKey) {

var i=0;

for (var len=fields.length; i<len; i++) {

if (fields[i].name == name) break;

}

if (i == fields.length) {

AP.require('request', function(request) {

request({

type: 'POST',

url: '/rest/api/2/field',

data: JSON.stringify({ "name": name,

  "description": desc,

  "type": type,

  "searcherKey": searchKey }),

  contentType: 'application/json; charset=utf-8',

    success: function(data) {

    data  =  AJS.$.parseJSON(data);    

    if (name == "Gantt Options") {

AP.getLocation(function(location){

  var baseUrl = location.replace(/plugins\/servlet\/ac\/de.polscheit.jira.plugins.gantt.cloud\/gantt-chart-configure/,"");

  AJS.$("#gantt-customfields").append("<li>"+name+" created, but you have to <a href='" + baseUrl + "secure/admin/ConfigureCustomField!default.jspa?customFieldId=" +  

                                                                                                     data.schema.customId + "'>create its options</a> named \"Milestone\" and \"Manual re-scheduling\" manually!</li>"); 

});    

    } else {

    AJS.$("#gantt-customfields").append("<li>"+name+" created</li>");

    }

    AJS.log(data);

    },

    error: function(data) {

    AJS.$("#gantt-customfields").append("<li>"+name+": " + data + "</li>");

    }

  });

});

} else {

AJS.$("#gantt-customfields").append("<li>"+name+": already exists</li>");

}

}


        addCustomfield("Gantt Options", "Issue-specific Gantt settings", "com.atlassian.jira.plugin.system.customfieldtypes:multicheckboxes", "com.atlassian.jira.plugin.system.customfieldtypes:multiselectsearcher");


Kind regards,

Frank

To unsubscribe from this group and stop receiving emails from it, send an email to atlassian-connect-dev+unsub...@googlegroups.com.

Matt Quail

unread,
Mar 3, 2014, 5:45:59 PM3/3/14
to atlassian-...@googlegroups.com
Frank,

Right. Unfortunately, there is no way to set custom field options in JIRA's public REST api. This doesn't help you in an Atlassian Connect plugin, but there is a REST resource for this under /globalconfig/ (it hasn't migrated to stable yet):

=Matt



To unsubscribe from this group and stop receiving emails from it, send an email to atlassian-connec...@googlegroups.com.

Sachin Gupta

unread,
Dec 18, 2015, 7:20:21 AM12/18/15
to Atlassian Connect Dev
Hi,

I am trying to do this POST request through a node js server but getting the following error:

{
    "code": 500,
    "message": "{\"message\":\"Can not deserialize instance of java.util.ArrayList out of START_OBJECT token\\n at [Source: org.apache.catalina.connector.CoyoteInputStream@598468c2; line: 1, column: 1]\"}
To unsubscribe from this group and stop receiving emails from it, send an email to atlassian-connect-dev+unsubscri...@googlegroups.com.

For more options, visit https://groups.google.com/groups/opt_out.
Reply all
Reply to author
Forward
0 new messages