I am trying to make a rest call to "/rest/api/latest/info" bamboo rest endpoint within Bamboo plugin by using "TrustedRequestFactory". However, I am getting the following error.
com.atlassian.spring.container. : Failed to find component: No bean named 'trustedRequestFactory' available
I have imported "TrustedRequestFactory" interface in atlassian-plugin.xml.
<component-importname="Trusted Request Factory" key="trusted-request-factory" interface="com.atlassian.sal.api.net.TrustedRequestFactory"/>
My code:
try{
final String baseUrl = getAdministrationConfiguration().getBaseUrl();
final TrustedRequestFactory trustedRequestFactory = (TrustedRequestFactory) ContainerManager.getComponent("trustedRequestFactory");
final TrustedRequest trustedRequest = trustedRequestFactory.createTrustedRequest(Request.MethodType.GET, baseUrl+"/rest/api/latest/info");
final String result = trustedRequest.execute();
bambooVersion=result;
} catch (Exception e) {
e.printStackTrace();
bambooVersion=e.toString();
}
I have found following documents for this purpose.
https://docs.atlassian.com/atlassian-bamboo/6.3.2/com/atlassian/sal/bamboo/trusted/BambooHttpClientTrustedRequestFactory.html
https://community.atlassian.com/t5/Answers-Developer-Questions/Call-Confluence-REST-from-within-Confluence/qaq-p/570337
I have two question for this problem:
- How can i make use of trustedRequestFactory?
- Is there an alternative way to call bamboo rest endpoint within the plugin. sd