Jira calls external REST Service - rest

My Problem: I want to introduce a new field in JIRA with status information from external REST Service (response is json).
Plan: Every Jira issue has a input field with some reference string. Behind this field there should be a panel, what should display informations from the external REST call (parsing response JSON is required).
Can someone give me some good info pages, how to tell JIRA to call external REST Service?

If you don't want to build it see:
nFeed
HTTP Feed Custom Field
If you want to build it yourself then start by following this tutorial on Creating a custom field type which is to more or less store a basic String within the database. (This would be the reference string)
You then have two options, the first is within the JiraCustomField class override the getVelocityParameters which was taken from How to call a java method from velocity Atlassian Answers question.
Then create a method (fetchValueFromWebService(String val)) that you would call that would contain code to query the REST Service based off the fields value that would be passed in from the velocity template. (E.g. $instance.fetchValueFromWebService($value))
To perform the actual web service call you can use any library you want, just see the Managing Dependencies documentation so it gets included in the plugin. (For example using the Jira Jersey version see this)
Your other option would be to within the view-basictext.vm have it use javascript and perform an AJAX to the web service by calling a function in your own JS file and dump that into a span that you have defined: (See Including Javascript and CSS resources)
<span id="webServiceValue"></span>
<script type="text/javascript">
fetchValueFromWebService($value);
</script>
You would however need to ensure that the webservice has Cross-origin resource sharing (CORS) enabled if you go the AJAX route.

Related

How to: Get Report Definition using SSRS RESTful API?

I have been working with the RESTful SSRS endpoint documentation at https://app.swaggerhub.com/apis/microsoft-rs/SSRS/2.0 and It states that I can retrieve the Report defintiion for my reports, however I cannot find any of the endpoints to do such?
From Microsoft docs:
The REST API can also be used to provide more advanced functionality,
such as:
Navigate the folder hierarchy Discover the contents of a folder
Download a report definition
Modify default report parameters Change
or execute a refresh plan A whole lot more
The REST API is a RESTful successor to the legacy SOAP API.
Maybe I am missing something?
I am able to get the Parameter Definitions, the report by ID,
however passing in any parameters such as
https://{myreportserver}/reports/api/v2.0/reports({id})?paramter1=somevalue
does not return any definition. I am trying to get a definition return so maybe I can render the report on a web application (or at minimum provide a pdf download of the report?)
Late to the game, but in case anyone else is looking for this answer, use this URL:
https://{myreportserver}/reports/api/v2.0/reports({id})?Content/$value

Calling IBM Function through HTTP

I created a function in IBM cloud which displays some JSON data when invoked. I am trying to figure out how client can consume this information. I am unable to find any information on net. I would like to preferable access the function through HTTP request or if that is not possible do it through some python script. Does anyone have more information on how this can be achieved?
Depending on the nature of your action/function, there are different ways to call it. In any case, you can find the required information about URL (and API key), by clicking the action in the action panel, and select 'endpoints' from there.
If you created a 'plain' action (i.e. one that accepts JSON and returns JSON), you will have to use the API key shown on the panel mentioned above. You can find it -- and the URL to use, in the 'Rest API' section. At the bottom of this page, there is also a complete curl command, which you can just copy & paste (and where you only need to insert the API key).
In case you created a web action (see here for details: https://console.bluemix.net/docs/openwhisk/openwhisk_webactions.html#openwhisk_webactions) , you can call it anonymously. The URL for that is different than the one referred to above -- you can find it in the 'web actions' section of the 'Endpoints' tab.

How to construct client context in AEM by passing values from an external system?

Is there a way to construct the client context in AEM by using values passed by an external website? The external website sends the user information such as IP address, page data, geolocation, etc. I want to construct the ClientContext JSON without using CQ_Analytics.ClientContextMgr.init, as the information is from an external system.
For eg: We know the location of a visitor to our website. We want to pass this value to AEM and set the client context so that we can get the targeted content for this location.
Our end goal is to get something like this (but we are trying to achieve this without constructing the JSON by ourselves):
CQ_Analytics.ClientContextMgr.clientcontext = JSON.parse('{"profile":{"country":"US"}}');
Is there any Javascript APIs provided by AEM to construct the JSON?
You need to extend the client context using AEM documentation provided at:
Creating a Custom Context Store Component
Follow the instructions till the Initialization part where you will need to populate the data in the jsp file for your extension.
So in your case it would be something this:
if(!locstore){
locstore = CQ_Analytics.JSONPStore.registerNewInstance("<%= store %>",
"<%= jsonpurl %>",{});
}
Where jsonpurl will be the location of your service that provides the external data in json(p) format. This will initialise your store with the values you want and you won't need to worry about the manual json handcrafting.
Client context is constructed on client side using the JS library in AEM. You will need some binding parameters to connect your external data source to the current client context.
The detailed tutorial can be found here.

Extract data from metadata list macro from Confluence's REST API

I'm trying to fetch the value of an item in a metadata list on a page in Confluence using the REST API. So far I have been able to extract fetch the body using a URL like this
https://acme.com/rest/api/content/105088446?expand=body.storage
(documentation here: https://developer.atlassian.com/confdev/confluence-server-rest-api/expansions-in-the-rest-api)
Or the full contents of the metadata list macro like this
https://acme.com/rest/api/content/105088446/history/10/macro/id/c65d00a3-49e2-40e5-a032-50b6c187d968
(documentation here: https://docs.atlassian.com/confluence/REST/latest/#content)
But neither of these are satisfactory. The first leaves a lot of parsing, the second requires I define the version of the page and even then returns the whole table that needs to be parsed.
I'm not sure if you are referring to the page properties (Page Properties Macro). If so you could try the masterdetails REST service.
rest/masterdetail/1.0/detailssummary/lines
You can use the REST API Browser to discover the parameters (note that this is part of the non-public API, so you need to check of the "Show only public APIs" checkbox to see it in the list).
There is a similar question on Atlassian Answers.

dotCMS REST API fetch template by its id

I consider using dotCMS and integrate it with other system by its rest API but in spite of ability to fetch content by its api I cannot fetch tempates defined in dotCMS.
With url api/content/type/xml/id/c12fe7e6-d338-49d5-973b-2d974d57015b I obtain as response following xml:
<contentlets>
<content>
<template>1763fa6e-91c0-464e-8b16-9a25d7ae6ce5</template>
<modDate>2015-12-10 10:58:56.098</modDate>
<cachettl>15</cachettl>
<title>About Us</title>
<httpsreq/>
<showOnMenu>true</showOnMenu>
<inode>84e2879a-7749-40f4-bded-9d59dbb2b1da</inode>
<____DOTNAME____>About Us</____DOTNAME____>
<disabledWYSIWYG>[]</disabledWYSIWYG>
<seokeywords>dotCMS Content Management System</seokeywords>
<host>48190c8c-42c4-46af-8d1a-0cd5db894797</host>
<lastReview>2015-12-10 10:58:56.093</lastReview>
<stInode>c541abb1-69b3-4bc5-8430-5e09e5239cc8</stInode>
<owner>dotcms.org.1</owner>
<friendlyname>About Us</friendlyname>
<identifier>c12fe7e6-d338-49d5-973b-2d974d57015b</identifier>
<redirecturl/>
<canonicalUrl/>
<pagemetadata>dotCMS</pagemetadata>
<languageId>1</languageId>
<seodescription>
dotCMS Content Management System demo site - About Quest
</seodescription>
<folder>1049e7fe-1553-4731-bdf9-ba069f1dc08b</folder>
<sortOrder>0</sortOrder>
<modUser>dotcms.org.1</modUser>
</content>
</contentlets>
Is there any possibility to fetch template by its id (here 1763fa6e-91c0-464e-8b16-9a25d7ae6ce5) and obtain html file as response or some xml with html content?
Ok so after some hours of source code analysis I think I can assume that there is no rest api implemented by dotCMS. Instead of this we can use java api and fetch such components like templates, containers etc. by calling methods which are responsible for fetching these components from database. Then we can implement our own rest services.
Templates in dotCMS govern the display of "pages" which can be made up of multiple content objects. If you want to return a content object that has formatting applied to it, take a look at the widget API here:
http://dotcms.com/docs/latest/remote-widgets
and how it can be used here:
http://dotcms.com/docs/latest/remote-widgets