Hi,
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.