Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

Rest api response to velocity template

ramya sree April 14, 2015

I want to create a gadget that calls rest api and get the response and send it to velocity template for displaying the response in the required format.

 

Please suggest

2 answers

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

Post a new question

0 votes
ramya sree April 14, 2015

Hi... I am able to get the response from rest api but I'm not understanding how to send the rest api response to a velocity template I am using this rest api /rest/api/2/search?jql=project=HEL AND priority=4 After getting the response, I want to list out the issue details description and some other fields of corresponding issues on the page. <?xml version="1.0" encoding="UTF-8" ?> <Module> <ModulePrefs title="__MSG_gadget.title__" title_url="__MSG_gadget.title.url__" description="__MSG_gadget.description__" author="Jobin Kuruvilla" author_email="jobinkk@gmail.com" height="150"> <Optional feature="gadget-directory"> <Param name="categories"> Other </Param> </Optional> <Require feature="dynamic-height"/> <Require feature="setprefs" /> <Require feature="views" /> <Require feature="oauthpopup" /> #supportedLocales("gadget.common") <Locale messages="__ATLASSIAN_BASE_URL__/download/resources/com.ramya.jira.sample/messages.xml"/> </ModulePrefs> <UserPref name="isConfigured" datatype="hidden" default_value="false"/> <UserPref name="refresh" datatype="hidden" default_value="false"/> <UserPref name="displayName" datatype="hidden" default_value="true"/> <UserPref name="displaypriority" datatype="hidden" default_value="true"/> <Content type="html" view="profile"> <![CDATA[ #requireResource("com.atlassian.jira.gadgets:common") #includeResources() Hellooooooo The Example goes like thissssssssssssssssss <script type="text/javascript"> (function () { var gadget = AJS.Gadget({ baseUrl: "__ATLASSIAN_BASE_URL__", config : { descriptor: function (args) { var gadget = this; return { fields: [ { userpref: "displayName", label: "Project ID", description:"projectID", type: "textarea" }, { userpref: "displayPriority", label: "issue priority", description:"Issue Priority", type: "textarea" } ] }; } }, view: { enableReload: true, onResizeAdjustHeight: true, template: function(args) { var gadget = this; console.log(args); var userDetails = AJS.$("<h1/>").text("Hello Ramyyyaaaa!"); gadget.getView().html(userDetails); }, args: [{ key: "user", ajaxOptions: function() { var gadget = this; var projectname=gadget.getPref("displayName"); var priority=gadget.getPref("displayPriority") var urlVal="/rest/api/2/search?jql=project="+projectname+" AND priority="+priority console.log("URLVAL",urlVal) return { url: urlVal }; } }] } }); })(); </script> ]]> </Content> </Module> After calling Rest api, the data is retrieved in "Template" of"view" parameter. Instead of that can we use velocity template and get the html built with the response?

0 votes
Pedro Cora
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
April 14, 2015

Ramya, could you describe a little more what is your expectation regarding this question? Are you facing problems to develop what you mentioned?

TAGS
AUG Leaders

Atlassian Community Events