Hi,
actually we are using Jira Server and Confluence Server. To create page structures in Confluence from Jira tickets, we have a script running in a postfunction. That uses the primary link which is actually Confluence Server.
The following example works:
import com.atlassian.applinks.api.ApplicationLink
import com.atlassian.applinks.api.ApplicationLinkService
import com.atlassian.applinks.api.application.confluence.ConfluenceApplicationType
import com.atlassian.sal.api.component.ComponentLocator
import com.atlassian.sal.api.net.Request
def applicationLinkService = ComponentLocator.getComponent(ApplicationLinkService.class)
ApplicationLink primaryConfluenceLink = applicationLinkService.getPrimaryApplicationLink(ConfluenceApplicationType.class)
def authenticatedRequestFactory = primaryConfluenceLink.createImpersonatingAuthenticatedRequestFactory()
// weiter gehen würde es z.B. mit
def request = authenticatedRequestFactory
.createRequest(Request.MethodType.GET, "rest/api/user?username=<USERNAME>")
.addHeader("Content-Type", "application/json")
String xml_result = request.execute()When switching to Cloud with Confluence then Confluence Cloud will also be primary link but we can't use the createImpersonatingAuthenticatedRequestFactory() method anymore.
Instead we have to use createAuthenticatedRequestFactory() with a BasicAuth AuthenticationProvider (https://docs.atlassian.com/applinks-api/3.2/com/atlassian/applinks/api/auth/AuthenticationProvider.html)
Actually I have no glue how to do this. Can anybody help with that?
I know there are other methods like UrlConnection or similar. But I want to use this classes.
Thanks for your suggestions.
Christof