Error while registering migration webhook

Hi,

We have a below code to register webhook for migration

public void registerWebhook(AtlassianHost host) {
		HttpHeaders headers = new HttpHeaders();
		headers.setAccept(Collections.singletonList(MediaType.APPLICATION_JSON));
		headers.setContentType(MediaType.APPLICATION_JSON);
		JsonObject endpointsData = new JsonObject();
		JsonArray endpoints = new JsonArray();
		String webhookUrl = addonBaseUrl + "/migration/notif";
		endpoints.add(new JsonPrimitive(webhookUrl));
		endpointsData.add("endpoints", endpoints);
		HttpEntity<String> request = new HttpEntity<>(endpointsData.toString(), headers);
		try {
			String migrationUrl = host.getBaseUrl() + ATLASSIAN_CONNECT_MIGRATION_URL + "/webhook";
			
			atlassianHostRestClients.authenticatedAsAddon()
					.put(migrationUrl, request);

		} catch (HttpStatusCodeException e) {
			String errorBody = e.getResponseBodyAsString();
			logger.error("Error Body:" + errorBody, e);
		} catch (Exception e) {
			logger.error("Failed to register migration webhook:" + e.getMessage(), e);
		}
	}

However we are facing an issue where we have started getting an error on production recently. An exception is thrown

2022-07-26 11:29:19.916 ERROR 16508 --- [dPoolExecutor-1] c.a.apps.cloud.migration.MigrationApi    : Error Body:
<html>
<head>
<title>Bad Request (400)</title>
<!--[if IE]><![endif]-->
<script type="text/javascript" >
var contextPath = '';
var DeferScripts = { deferState: 'disabled' };
</script>
<script>
window.WRM=window.WRM||{};window.WRM._unparsedData=window.WRM._unparsedData||{};window.WRM._unparsedErrors=window.WRM._unparsedErrors||{};

Client has started with migration. However I am not able to receive migration events and not able to update migration status, as webhook was not registered.

How can I fix this issue and update these migration status to FAILED/SUCCESS?

Please note this code is working and tested on local and qa environment

Thanks

Hi @shiv,

Thanks for contacting Developer Community with this issue. As this works locally and in QA, and looking at the error I don’t think your webhook request is getting through to Atlassian.

The error you’re seeing doesn’t look like something that would come from our servers. Although a HTTP 400 indicates the request was badly formed, is there a proxy or firewall between your production servers and Atlassian?

What does the whole error message look like? It is an Atlassian page?

Regards,
James.

1 Like

This is the screenshot of html page we get in response

badrequest

Below is the html response

<html>
<head>
<title>Bad Request (400)</title>
<!--[if IE]><![endif]-->
<script type="text/javascript" >
var contextPath = '';
var DeferScripts = { deferState: 'disabled' };
</script>
<script>
window.WRM=window.WRM||{};window.WRM._unparsedData=window.WRM._unparsedData||{};window.WRM._unparsedErrors=window.WRM._unparsedErrors||{};
WRM._unparsedData["com.atlassian.plugins.atlassian-plugins-webresource-plugin:context-path.context-path"]="\"\"";
WRM._unparsedData["com.atlassian.plugins.atlassian-plugins-webresource-rest:curl.cross-origin-resources"]="false";
WRM._unparsedData["jira.webresources:feature-flags.feature-flag-data"]="{\"enabled-feature-keys\":[\"com.atlassian.jira.projects.issuenavigator\",\"connect.no-applinks\",\"nps.survey.inline.dialog\",\"atlassian.aui.raphael.disabled\",\"com.atlassian.jira.projects.ProjectCentricNavigation.Switch\"],\"feature-flag-states\":{\"jira.feature.flag.board.issue.modal.labs\":true,\"com.atlassian.jira.plugins.mail.internal\":false,\"com.atlassian.jira.feature.flag.for.TestFeatureFlagResource\":false,\"jira.feature.rest.single.step.avatar.upload\":true,\"jira.ondemand.maintain.trusted.apps\":true}}";
WRM._unparsedData["com.atlassian.jira.jira-client-analytics-plugin:analytics-context-provider.client-analytic-descriptors"]="{\"analyticsResource\":{\"jira-core\":{\"events\":{\"issue.comment.added\":{\"trigger\":\"click #issue-comment-add-submit\",\"properties\":{\"comment-length\":\"value.length #issue-comment-add #comment\"}}}}},\"tenantId\":\"169eb115-41b1-4e7e-829d-c823b020cda4\",\"env\":\"prod\"}";
WRM._unparsedData["jira.webresources:default-comment-security-level.DefaultCommentSecurityLevelHelpLink"]="{\"extraClasses\":\"default-comment-level-help\",\"title\":\"Commenting on an Issue\",\"url\":\"https://confluence.atlassian.com/display/JIRACORECLOUD/Editing+and+collaborating+on+issues#Editingandcollaboratingonissues-addcommentsCommentingonissues\",\"isLocal\":false}";
WRM._unparsedData["jira.webresources:key-commands.shortcuts"]="[{\"moduleKey\":\"go-to-dashboard-kb-shortcut\",\"keys\":[[\"g\",\"d\"]],\"context\":\"global\",\"op\":\"goTo\",\"param\":\"/secure/Dashboard.jspa\"},{\"moduleKey\":\"browse-project-kb-shortcut\",\"keys\":[[\"g\",\"p\"]],\"context\":\"global\",\"op\":\"execute\",\"param\":\"var elem = jQuery(\\\"#browse_link\\\");\\n                if (elem.length \u003e 0) {\\n                    window.location.href = elem.attr(\\\"href\\\");\\n                }\"},{\"moduleKey\":\"issue-navigator-kb-shortcut\",\"keys\":[[\"g\",\"i\"]],\"context\":\"global\",\"op\":\"execute\",\"param\":\"var elem = jQuery(\\\"#find_link\\\");\\n                if (elem.length \u003e 0) {\\n                    window.location.href = elem.attr(\\\"href\\\");\\n                }\"},{\"moduleKey\":\"admin.quicksearch.dialog.shortcut\",\"keys\":[[\"g\",\"g\"]],\"context\":\"global\",\"op\":\"execute\",\"param\":\"JIRA.Shifter.show();\"},{\"moduleKey\":\"quicksearch\",\"keys\":[[\"/\"]],\"context\":\"global\",\"op\":\"moveToAndFocus\",\"param\":\"#quickSearchInput, #admin-quick-nav-field\"},{\"moduleKey\":\"create.issue\",\"keys\":[[\"c\"]],\"context\":\"global\",\"op\":\"moveToAndClick\",\"param\":\"#header .create-issue\"},{\"moduleKey\":\"shifter\",\"keys\":[[\".\"]],\"context\":\"global\",\"op\":\"execute\",\"param\":\"JIRA.Shifter.show();\"},{\"moduleKey\":\"help\",\"keys\":[[\"?\"]],\"context\":\"global\",\"op\":\"click\",\"param\":\"#keyshortscuthelp\"}]";
WRM._unparsedData["com.atlassian.plugins.atlassian-connect-plugin:dialog-options.data"]="{\"allJsVersion\":\"1.3.15\",\"dialogOptions\":{\"com.atlassian.jira.spreadsheets__open-in-excel\":{\"height\":\"280px\",\"chrome\":false,\"width\":\"480px\"},\"com.atlassian.jira.spreadsheets__open-in-gsheets\":{\"height\":\"280px\",\"chrome\":false,\"width\":\"480px\"}},\"inlineDialogOptions\":{},\"dialogModules\":{\"atlassian-outlook-integration\":{\"email-deletion-confirmation-dialog\":{\"cacheable\":false,\"options\":{\"height\":\"148px\",\"width\":\"400px\"},\"key\":\"email-deletion-confirmation-dialog\"},\"email-view-dialog\":{\"cacheable\":false,\"options\":{\"size\":\"maximum\"},\"key\":\"email-view-dialog\"}},\"jira-slack-integration\":{\"connected-channels-deletion-confirmation-dialog\":{\"cacheable\":false,\"options\":{\"size\":\"maximum\"},\"key\":\"connected-channels-deletion-confirmation-dialog\"},\"connected-channels-new-connection-dialog\":{\"cacheable\":false,\"options\":{\"size\":\"maximum\"},\"key\":\"connected-channels-new-connection-dialog\"},\"connected-channels-update-connection-dialog\":{\"cacheable\":false,\"options\":{\"size\":\"maximum\"},\"key\":\"connected-channels-update-connection-dialog\"}},\"stspg-jira-ops\":{\"unlink-incident\":{\"cacheable\":false,\"options\":{\"height\":\"232\",\"chrome\":false,\"width\":\"432\"},\"key\":\"unlink-incident\"}}}}";
WRM._unparsedData["com.atlassian.plugins.atlassian-connect-plugin:jira-date-picker-widget.config"]="{\"dateFormat\":\"%e/%b/%y\",\"dateTimeFormat\":\"%e/%b/%y %I:%M %p\",\"timeFormat\":\"12\",\"firstDay\":1,\"useISO8601WeekNumbers\":false}";
WRM._unparsedData["jira.webresources:dateFormatProvider.dateFormat"]="{\"meridiem\":[\"AM\",\"PM\"],\"eras\":[\"BC\",\"AD\"],\"months\":[\"January\",\"February\",\"March\",\"April\",\"May\",\"June\",\"July\",\"August\",\"September\",\"October\",\"November\",\"December\"],\"monthsShort\":[\"Jan\",\"Feb\",\"Mar\",\"Apr\",\"May\",\"Jun\",\"Jul\",\"Aug\",\"Sep\",\"Oct\",\"Nov\",\"Dec\"],\"weekdaysShort\":[\"Sun\",\"Mon\",\"Tue\",\"Wed\",\"Thu\",\"Fri\",\"Sat\"],\"weekdays\":[\"Sunday\",\"Monday\",\"Tuesday\",\"Wednesday\",\"Thursday\",\"Friday\",\"Saturday\"]}";
WRM._unparsedData["com.atlassian.servicedesk.frontend-webpack-plugin:data-provider.webpack-meta"]="{\"locale\":\"en-US\",\"publicPath\":\"//d1km8z6vsjbsdc.cloudfront.net/atl-vertigo--shard-jira-prod-eu-28--5--jres.atlassian.net/s/azc3hx/b/8/9567c640cc6984cc376aa057bb91f0e1b5b330e0/_/download/resources/com.atlassian.servicedesk.frontend-webpack-plugin:webpack-async-chunks/\"}";
WRM._unparsedData["com.atlassian.applinks.applinks-plugin:applinks-common-exported.applinks-types"]="{\"crowd\":\"Crowd\",\"confluence\":\"Confluence\",\"remote.plugin.container\":\"Atlassian Connect\",\"fecru\":\"FishEye / Crucible\",\"stash\":\"Bitbucket Server\",\"jira\":\"JIRA\",\"bamboo\":\"Bamboo\",\"generic\":\"Generic Application\"}";
WRM._unparsedData["com.atlassian.applinks.applinks-plugin:applinks-common-exported.entity-types"]="{\"singular\":{\"fecru.project\":\"Crucible Project\",\"fecru.repository\":\"FishEye Repository\",\"stash.project\":\"Bitbucket Server Project\",\"generic.entity\":\"Generic Project\",\"confluence.space\":\"Confluence Space\",\"bamboo.project\":\"Bamboo Project\",\"jira.project\":\"JIRA Project\"},\"plural\":{\"fecru.project\":\"Crucible Projects\",\"fecru.repository\":\"FishEye Repositories\",\"stash.project\":\"Bitbucket Server Projects\",\"generic.entity\":\"Generic Projects\",\"confluence.space\":\"Confluence Spaces\",\"bamboo.project\":\"Bamboo Projects\",\"jira.project\":\"JIRA Projects\"}}";
WRM._unparsedData["com.atlassian.applinks.applinks-plugin:applinks-common-exported.authentication-types"]="{\"com.atlassian.applinks.api.auth.types.BasicAuthenticationProvider\":\"Basic Access\",\"com.atlassian.applinks.api.auth.types.CorsAuthenticationProvider\":\"CORS\",\"com.atlassian.applinks.api.auth.types.OAuthAuthenticationProvider\":\"OAuth\",\"com.atlassian.applinks.api.auth.types.TwoLeggedOAuthAuthenticationProvider\":\"OAuth\",\"com.atlassian.applinks.api.auth.types.TwoLeggedOAuthWithImpersonationAuthenticationProvider\":\"OAuth\"}";
WRM._unparsedData["com.atlassian.crowd.user-provisioning-vertigo-plugin:create-users-resources.isSiteAdmin"]="false";
WRM._unparsedData["jira.webresources:avatar-picker.data"]="{\"isEnabled\":true,\"url\":\"/plugins/servlet/redirectToProfile?target=edit-avatar\"}";
WRM._unparsedData["com.atlassian.jira.jira-header-plugin:dismissedFlags.flags"]="{\"dismissed\":[]}";
WRM._unparsedData["com.atlassian.servicedesk.core-ui:util-help-links.help-links"]="{\"help\":{\"sla.settings\":\"https://confluence.atlassian.com/display/SERVICEDESKCLOUD/setting+up+slas\",\"email.settings\":\"https://confluence.atlassian.com/display/SERVICEDESKCLOUD/Receiving+requests+by+email\",\"servicedesk.organizations\":\"https://confluence.atlassian.com/display/SERVICEDESKCLOUD/Setting+up+service+desk+users#Settingupservicedeskusers-manageorgsManageorganizations\",\"request.type\":\"https://confluence.atlassian.com/display/SERVICEDESKCLOUD/configuring+request+types+and+workflows\",\"email.setup\":\"https://confluence.atlassian.com/display/SERVICEDESKCLOUD/Receiving+requests+by+email\",\"servicedesk.users\":\"https://confluence.atlassian.com/display/SERVICEDESKCLOUD/Setting+up+service+desk+users\",\"managing.queues\":\"https://confluence.atlassian.com/display/SERVICEDESKCLOUD/Setting+up+queues+for+your+team\",\"documentation.home\":\"https://confluence.atlassian.com/display/SERVICEDESKCLOUD/Jira+Service+Desk+Cloud+documentation\",\"multi.language.portal\":\"https://confluence.atlassian.com/display/SERVICEDESKCLOUD/Translating+your+customer+portal+and+supporting+multiple+languages\",\"default\":\"https://confluence.atlassian.com/display/SERVICEDESKCLOUD/\",\"portal.settings\":\"https://confluence.atlassian.com/display/SERVICEDESKCLOUD/best+practices+for+designing+the+customer+portal\",\"setting.up.reports\":\"https://confluence.atlassian.com/display/SERVICEDESKCLOUD/Setting+up+service+desk+reports\",\"getting.started.agent\":\"https://confluence.atlassian.com/display/SERVICEDESKCLOUD/Getting+started+for+service+desk+agents\",\"queues.setup\":\"https://confluence.atlassian.com/display/SERVICEDESKCLOUD/setting+up+queues+for+your+team\",\"request.settings.help.bubble\":\"https://confluence.atlassian.com/display/SERVICEDESKCLOUD/Managing+access+to+your+service+desk\",\"email.settings.suitablerequest\":\"https://confluence.atlassian.com/display/SERVICEDESKCLOUD/Receiving+requests+by+email#Receivingrequestsbyemail-suitablerequest\",\"servicedesk.software.teams\":\"https://confluence.atlassian.com/display/SERVICEDESKCLOUD/best+practices+for+software+teams+using+jira+service+desk\",\"create.space.help\":\"https://confluence.atlassian.com/display/SERVICEDESKCLOUD/Serving+customers+with+a+knowledge+base#serving-customers-with-a-knowledge-base-createpermission\",\"admin.notifications.config\":\"https://confluence.atlassian.com/display/SERVICEDESKCLOUD/Configuring+service+desk+notifications\",\"email.settings.troubleshooting\":\"https://confluence.atlassian.com/display/SERVICEDESKCLOUD/Troubleshooting+issues+with+the+email+channel\",\"troubleshoot.requesttype\":\"https://confluence.atlassian.com/display/SERVICEDESKCLOUD/Troubleshooting+issues+with+request+types\",\"approvals.configuration\":\"https://confluence.atlassian.com/display/SERVICEDESKCLOUD/Configuring+JIRA+Service+Desk+approvals\",\"public.signup\":\"https://confluence.atlassian.com/display/SERVICEDESKCLOUD/Configuring+public+signup\",\"resolve.permission.scheme.errors\":\"https://confluence.atlassian.com/display/SERVICEDESKCLOUD/Resolving+permission+scheme+errors\",\"knowledge.base\":\"https://confluence.atlassian.com/display/SERVICEDESKCLOUD/Serving+customers+with+a+knowledge+base\",\"getting.started\":\"https://confluence.atlassian.com/display/SERVICEDESKCLOUD/Getting+started+with+JIRA+Service+Desk\",\"invite.customers\":\"https://confluence.atlassian.com/display/SERVICEDESKCLOUD/Managing+access+to+your+service+desk\"},\"kb\":{\"default\":\"https://confluence.atlassian.com/display/SDKB/\",\"legacytransition\":\"https://confluence.atlassian.com/display/SDKB/Replacing+legacy+automatic+transitions+with+automation+rules\",\"umtroubleshoot\":\"https://confluence.atlassian.com/display/SDKB/Troubleshooting+issues+with+service+desk+user+management\"}}";
WRM._unparsedData["com.atlassian.servicedesk.core-ui:util-base-url.base-url"]="\"https://3spin-learning.atlassian.net\"";
WRM._unparsedData["com.atlassian.jira.ext.calendar:tipDataProvider.tip"]="{\"suppressTip\":false}";
WRM._unparsedData["com.atlassian.jira.plugins.jira-browser-metrics:browser-metrics-client.git-commit-id"]="\"9567c640cc6984cc376aa057bb91f0e1b5b330e0\"";
WRM._unparsedData["jira.webresources:user-message-flags.adminLockout"]="{}";
WRM._unparsedData["com.atlassian.plugins.helptips.jira-help-tips:help-tip-manager.JiraHelpTipData"]="{\"anonymous\":true}";
if(window.WRM._dataArrived)window.WRM._dataArrived();</script>
<link type="text/css" rel="stylesheet" href="//d1km8z6vsjbsdc.cloudfront.net/atl-vertigo--shard-jira-prod-eu-28--5--jres.atlassian.net/s/d41d8cd98f00b204e9800998ecf8427e-CDN/azc3hx/b/8/ab3d848d53b16dcfc5b97906de2c4e18/_/download/contextbatch/css/_super/batch.css?relative-url=true" data-wrm-key="_super" data-wrm-batch-type="context" media="all">
<link type="text/css" rel="stylesheet" href="//d1km8z6vsjbsdc.cloudfront.net/atl-vertigo--shard-jira-prod-eu-28--5--jres.atlassian.net/s/d41d8cd98f00b204e9800998ecf8427e-CDN/azc3hx/b/8/c905625cdcff9dd082c9c0110003c4e8/_/download/contextbatch/css/atl.general,jira.general,atl.global,jira.global,-_super/batch.css?agile_global_admin_condition=true&amp;feature-enable-ip-allowlisting-alerts=true&amp;jag=true&amp;relative-url=true" data-wrm-key="atl.general,jira.general,atl.global,jira.global,-_super" data-wrm-batch-type="context" media="all">
<script type="text/javascript" src="//d1km8z6vsjbsdc.cloudfront.net/atl-vertigo--shard-jira-prod-eu-28--5--jres.atlassian.net/s/d41d8cd98f00b204e9800998ecf8427e-CDN/azc3hx/b/8/27c53437dc56ffa3c60ce7927febc840/_/download/contextbatch/js/_super/batch.js?locale=en-US" data-wrm-key="_super" data-wrm-batch-type="context" data-initially-rendered></script>
<script type="text/javascript" src="//d1km8z6vsjbsdc.cloudfront.net/atl-vertigo--shard-jira-prod-eu-28--5--jres.atlassian.net/s/d41d8cd98f00b204e9800998ecf8427e-CDN/azc3hx/b/8/6a7f7b0bd62ce102d650637f8b41c765/_/download/contextbatch/js/atl.general,jira.general,atl.global,jira.global,-_super/batch.js?agile_global_admin_condition=true&amp;feature-enable-ip-allowlisting-alerts=true&amp;jag=true&amp;locale=en-US" data-wrm-key="atl.general,jira.general,atl.global,jira.global,-_super" data-wrm-batch-type="context" data-initially-rendered></script>
<script>
########## script here can be found in attached txt file ############
</script>
<link type="text/css" rel="stylesheet" href="//d1km8z6vsjbsdc.cloudfront.net/3spin-learning.atlassian.net/s/d41d8cd98f00b204e9800998ecf8427e-CDN/azc3hx/b/8/35cc4bc02ceddc27292a480933a65ddb/_/download/jira-lf-contextbatch/css/jira.global.look-and-feel,-_super/batch.css?relative-url=true" data-wrm-key="jira.global.look-and-feel,-_super" data-wrm-batch-type="context" media="all">
<script>
window.WRM=window.WRM||{};window.WRM._unparsedData=window.WRM._unparsedData||{};window.WRM._unparsedErrors=window.WRM._unparsedErrors||{};
WRM._unparsedData["_wrmBatchContents"]="{\"js\":{},\"css\":{\"jira.global.look-and-feel,-_super\":[\"jira.webresources:jira-lookandfeel-all.lf-adg3\",\"jira.webresources:look-and-feel-affected-styles-all\",\"_context:jira.global.look-and-feel\"]}}";
if(window.WRM._dataArrived)window.WRM._dataArrived();</script>
<meta name="application-name" content="JIRA" data-name="jira" data-version="1001.0.0-SNAPSHOT">
</head>
<body id="jira" class="aui-layout aui-style-default page-type-message"  data-version="1001.0.0-SNAPSHOT" >
<div class="aui-page-panel"><div class="aui-page-panel-inner">
<section class="aui-page-panel-content">
<header class="aui-page-header"><div class="aui-page-header-inner">
<div class="aui-page-header-main">
<h1>Bad Request (400)</h1>
</div><!-- .aui-page-header-main -->
</div><!-- .aui-page-header-inner --></header><!-- .aui-page-header -->
<div class="aui-message aui-message-warning warning">
<p>Encountered a <code>&quot;400 - Bad Request&quot;</code> error while loading this page.</p>
<p>The add-on is not enabled.</p>
<p><a href="/secure/MyJiraHome.jspa">Go to Jira home</a></p>
</div>
</section><!-- .aui-page-panel-content -->
</div><!-- .aui-page-panel-inner --></div><!-- .aui-page-panel -->
</body>
</html>

Full html response is attached as error.txt

error.txt (66.8 KB)

Hi @shiv,

The error says The add-on is not enabled. Are you sure the add-on is correctly installed in the instance?

Is this only happening with one customer and one site?

Regards,
James.

1 Like

Yes, addon is installed correctly. Infact we have migrated addon data offline and customer has also confirmed that data is migrated and he can use addon.
However in the server migration console, it still shows data migration in progress for our app as we are not able to update migration status. This has happened with this customer only. this has not happened for migration we did before this. Is there a way to update migration status for this customer? which is still in progress.

Hi @shiv,

If you don’t have a transferId then there’s no way to update the progress.

You can get the transferId by making a GET /rest/atlassian-connect/1/migration/transfer/recent (see https://developer.atlassian.com/platform/app-migration/rest/api-group-transfer-retrieval-api/#api-transfer-recent-get). This will return all active transfers for your app in that host.

Once you have it, you can post progress update through POST /rest/atlassian-connect/1/migration/progress/{transferId}.

I recommend making regular (e…g once every severla days or so) requests to that endpoint for each site that has a webhook registered to ensure you haven’t missed any migrations.

If you don’t update the progress, it will time out in 14 days from the start. This will update in the UI as well. As this is only a UI issue it’s unlikely to cause an issue as there’s probably no underlying thread running the app migration code, or if there is, it’s stalled.

Regards,
James.

1 Like

Thanks, will try and see if I can still get active transfers for our app