How to remove Application link using a REST endpoint
The content on this page relates to platforms which are not supported. Consequently, Atlassian Support cannot guarantee providing any support for it. Please be aware that this material is provided for your information only and using it is done so at your own risk.
Purpose
This article instructs how to remove an Application Link using a REST endpoint. The use case is when configuring a test or staging server with scripting, disabling the AppLink with a script is easier than removing it manually.
Solution
The below examples require an authenticated session, and also for websudo (secure sessions) to be disabled. Given this is for a test server this should be acceptable, and can be done as per Configuring secure administrator sessions.
Identify the Application Link(s) to be removed by performing a
GET
on<BASE_URL>/rest/applinks/1.0/listApplicationlinks
. This will provide something such as the below:<?xml version="1.0"?> <list> <list xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="linkAndAuthProviderEntity"> <application> <link href="http://captain-planet.example.com:60631/jira6312/rest/applinks/1.0/applicationlink/3e3c8fef-6f20-34c5-9e1f-624f0eacd943" rel="self"/> <id>3e3c8fef-6f20-34c5-9e1f-624f0eacd943</id> <typeId>confluence</typeId> <name>Confluence</name> <displayUrl>http://captain-planet.example.com:50587/conf5817</displayUrl> <iconUrl>http://captain-planet.example.com:60631/jira6312/s/en_US-qbihy0/6343/4/4.2.5/_/download/resources/com.atlassian.applinks.applinks-plugin:applinks-images/images/types/16confluence.png</iconUrl> <rpcUrl>http://captain-planet.example.com:50587/conf5817</rpcUrl> <isPrimary>true</isPrimary> <isSystem>false</isSystem> </application> <configuredOutboundAuthenticators>com.atlassian.applinks.api.auth.types.OAuthAuthenticationProvider</configuredOutboundAuthenticators> <configuredOutboundAuthenticators>com.atlassian.applinks.api.auth.types.TwoLeggedOAuthAuthenticationProvider</configuredOutboundAuthenticators> <configuredInboundAuthenticators>com.atlassian.applinks.api.auth.types.OAuthAuthenticationProvider</configuredInboundAuthenticators> <configuredInboundAuthenticators>com.atlassian.applinks.api.auth.types.TwoLeggedOAuthAuthenticationProvider</configuredInboundAuthenticators> <hasIncomingAuthenticationProviders>true</hasIncomingAuthenticationProviders> <hasOutgoingAuthenticationProviders>true</hasOutgoingAuthenticationProviders> <appLinkState>OK</appLinkState> <isSystem>false</isSystem> <entityTypeIdStrings>confluence.space</entityTypeIdStrings> </list> </list>
- Retrieve the
id
from the above query, for example using XPath this is/list/list/application/id
. - Use that to enter into the URL
<BASE_URL>/rest/applinks/2.0/applicationlink/<id>
, and send aDELETE
to that URL. If we use the example above this ishttp://captain-planet.example.com:60631/jira6312/rest/applinks/2.0/applicationlink/3e3c8fef-6f20-34c5-9e1f-624f0eacd943
. - This will delete the Application Link.
This can be automated with something similar to the below Shell script, replacing admin:sphere with the username and password.
curl -u admin:sphere http://captain-planet.example.com:60631/jira6312/rest/applinks/1.0/listApplicationlinks | xmllint --xpath '/list/list/application/id/text()' - > id.txt
curl -u admin:sphere -X DELETE 'http://captain-planet.example.com:60631/jira6312/rest/applinks/2.0/applicationlink/'$(cat id.txt)
A successful result will be output something similar to the below. This does not delete the application link in the linked instance (in this example, Confluence).
<?xml version="1.0" encoding="UTF-8" standalone="yes"?><status><status-code>200</status-code><message>Deleted application with id '3e3c8fef-6f20-34c5-9e1f-624f0eacd943'</message></status>