REST call to existing JIRA API


I have a question about sending REST calls to Jira API. I have a field in preferences page:

  userpref: "projectid",
  label: gadget.getMsg("timesheet.sprint.projectsummary.label"),
  type: "select",
  selected: projectidPref,
  options: args.projects.values

and I get data for this field by calling my exposed endpoint:

args: [{
  key: "projects",
  ajaxOptions: "/rest/timesheet-gadget/1.0/project.json"

I get result like this (and it works fine):

  "values": [{
    "label": "JIRAMetrics",
    "value": "10000"
  }, {
    "label": "CISS",
    "value": "10001"

Question is how to make REST call to existing JIRA API (not my endpoint). I tried:

args: [{
  key: "projects",
  ajaxOptions: "/rest/api/2/project"

but then I get json which has no label->value pair, and AJS doesn’t know how to handle this:

    "expand": "description,lead,url,projectKeys",
    "self": "http://localhost:2990/jira/rest/api/2/project/10000",
    "id": "10000",
    "key": "JM",
    "name": "JIRAMetrics",
    "avatarUrls": {
      "48x48": "http://localhost:2990/jira/secure/projectavatar?avatarId=10324",
      "24x24": "http://localhost:2990/jira/secure/projectavatar?size=small&avatarId=10324",
      "16x16": "http://localhost:2990/jira/secure/projectavatar?size=xsmall&avatarId=10324",
      "32x32": "http://localhost:2990/jira/secure/projectavatar?size=medium&avatarId=10324"
    "projectTypeKey": "business"

What is the proper way to call and handle existing JIRA API from AJS and how to handle the response? Is there any example?

Thanks in advance.

This is a label:value pair. You should be able to extract the info easily in Javascript. The json response is an array of projects, each with a set of label:value pairs. Am I missing something?

label:value pair I get in response from my exposed endpoint(my api). When I call jira rest api I get “expand” object (I would need to map this object in javascript to get label:value pair-which I use for select field). I thought that atlassian probably solved this in AJS, so I don’t need to do mapping…