- Page restrictions apply
- Attachments:8
- Added by Arie Murdianto, last edited by Arie Murdianto on Jul 06, 2009 (view change)
|
This plugin is to utilize the existing webservice plugins which are XMLRPC plugin and SOAP plugin, including Confluence Remote API plugin DetailsAs per summary, this plugin can be used to expose the functionalities of the existing SOAP and XMLRPC plugins, including the default plugin which is bundled by Confluence (Confluence Remote API plugin). You can switch this plugin to be able to expose either XMLRPC or SOAP. If you switch to XMLRPC, Confluence JSON webservice will expose the existing XMLRPC plugin, and also if you switch to SOAP, then this plugin can expose the existing SOAP plugin.
For more example on how to use the plugin, you can refer to the Documentation link of this plugin. In order to use the plugin, what you need to do is to request a servlet of this plugin. This servlet is processing what service and what method that you want to consume. The URL that is used to consume JSON services, has a pattern. The following is the pattern of the URL address that you need so that you can consume the service: http://<confluencePath>/plugins/servlet/<serviceKey>/<methodName>?parameters=<methodsParameter>&callback=<callback>
In this page, I will demonstrate a few ways on how to use this plugin. Most of the services that I use in this example are bundled in Confluence distribution. The services are Confluence Remote API and Confluence Blogging RPC Plugin. Example:{*}Calling method getPage from Confluence Remote API using browser:*In the above example, the service is accessed via the following URL: http://localhost:8080/plugins/servlet/jsonService/confluence-xmlrpc/getPage?parameters=BiqCJuhH2a;262148 Overview
Bugs & Feature RequestsBug reports and feature requests are available in JIRA. This plugin does not have any macros. Examples Example 1:{*}Calling method getPage from Confluence Remote API using browser:*In the above example, the service is accessed via the following URL: http://localhost:8080/plugins/servlet/jsonService/confluence-xmlrpc/getPage?parameters=BiqCJuhH2a;262148 <html> <head> <script src="jquery.js"></script> <script> $(document).ready(function(){ $.getJSON('http://localhost:8080/plugins/servlet/jsonService/confluence-xmlrpc/getPage?parameters=BiqCJuhH2a;262148&callback=?', function ( data ) { alert('test'+data.title); }); }); </script> </head> <body> </body> </html> Example 3: import net.sf.json.JSONArray; import net.sf.json.JSONObject; import net.sf.json.util.JSONDynaBean; import org.apache.commons.httpclient.*; import org.apache.commons.httpclient.methods.*; import org.apache.commons.httpclient.params.HttpMethodParams; import java.io.*; import java.util.List; public class FetchJSONService { public static void main(String[] args) { HttpClient client = new HttpClient(); GetMethod methodLogin = new GetMethod("http://localhost:8080/plugins/servlet/jsonService/confluence-soap/login?parameters=admin;arie&callback=noLabel"); methodLogin.getParams().setParameter(HttpMethodParams.RETRY_HANDLER,new DefaultHttpMethodRetryHandler(3, false)); try { client.executeMethod(methodLogin); String token = methodLogin.getResponseBodyAsString(); token = token.substring(1, token.length()-1); GetMethod method = new GetMethod("http://localhost:8080/plugins/servlet/jsonService/confluence-soap/getMostPopularLabels?parameters="+token+";10&callback=noLabel"); method.getParams().setParameter(HttpMethodParams.RETRY_HANDLER,new DefaultHttpMethodRetryHandler(3, false)); int statusCode = client.executeMethod(method); String responseBody = method.getResponseBodyAsString(); System.out.println("the retrieved token: "+ token); System.out.println(responseBody); JSONArray jsonArray = JSONArray.fromString(responseBody); List<JSONDynaBean> listOfLabel = JSONArray.toList(jsonArray); for(JSONDynaBean item:listOfLabel) { System.out.println("Available label: "+item.get("name")); } } catch (Exception e) { e.printStackTrace(); } } } The above code will give you the available labels in your Confluence instance as illustrated below: Example 4:
Example 5 http://localhost:8080/plugins/servlet/jsonService/blogger-xmlrpc/getUserInfo?parameters=confluence;admin;arie The above url produces the following: Note: By downloading the product below, you agree to CustomWare's product license agreement. In order to install you can download the plugin here and then install it via plugin manager. Alternatively, you can use repository client plugin to install Confluence JSON webservice plugin. |
|
Connect JIRA and SharePoint |
Atlassian Professional Services |
Atlassian Training |
Discussions