diff --git a/libs/logic-apps-shared/src/designer-client-services/lib/base/connection.ts b/libs/logic-apps-shared/src/designer-client-services/lib/base/connection.ts index 381656650ec..653cf991ad5 100644 --- a/libs/logic-apps-shared/src/designer-client-services/lib/base/connection.ts +++ b/libs/logic-apps-shared/src/designer-client-services/lib/base/connection.ts @@ -1,6 +1,6 @@ /* eslint-disable no-param-reassign */ import { SwaggerParser } from '../../../parsers'; -import type { Connection, OpenAPIV2, Connector } from '../../../utils/src'; +import type { Connection, OpenAPIV2, Connector, TestConnectionObject } from '../../../utils/src'; import { ArgumentException, isArmResourceId, @@ -205,15 +205,28 @@ export abstract class BaseConnectionService implements IConnectionService { protected async testConnection(connection: Connection): Promise { let response: HttpResponse | undefined = undefined; - response = await this.requestTestConnection(connection); - if (response) this.handleTestConnectionResponse(response); + const testLink = connection.properties?.testLinks?.[0]; + try { + if (testLink) { + response = await this.requestTestConnection(testLink); + if (response) this.handleTestConnectionResponse(response); + } + } catch (testLinkError: any) { + try { + const testRequest = connection.properties?.testRequests?.[0]; + if (testRequest) { + response = await this.requestTestConnection(testRequest); + if (response) this.handleTestConnectionResponse(response); + } + } catch (testRequestError: any) { + throw testLinkError ?? testRequestError; + } + } } - protected async requestTestConnection(connection: Connection): Promise | undefined> { - const testLinks = connection.properties?.testLinks; - const testRequests = connection.properties?.testRequests; + protected async requestTestConnection(testConnectionObj: TestConnectionObject): Promise | undefined> { const { httpClient } = this.options; - const { method: httpMethod, requestUri: uri, body } = testRequests?.[0] ?? testLinks?.[0] ?? {}; + const { method: httpMethod, requestUri: uri, body } = testConnectionObj; if (!httpMethod || !uri) return; const method = httpMethod.toUpperCase() as HTTP_METHODS; diff --git a/libs/logic-apps-shared/src/utils/src/lib/models/connection.ts b/libs/logic-apps-shared/src/utils/src/lib/models/connection.ts index 5566a77b197..94496e9cf0a 100644 --- a/libs/logic-apps-shared/src/utils/src/lib/models/connection.ts +++ b/libs/logic-apps-shared/src/utils/src/lib/models/connection.ts @@ -57,7 +57,7 @@ export interface ConnectionProperties { export type Connection = ArmResource; -interface TestConnectionObject { +export interface TestConnectionObject { body?: string; method: string; requestUri: string; diff --git a/package-lock.json b/package-lock.json index f9b08a0c782..4bae5f491ea 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@microsoft/logicappsux", - "version": "3.0.0", + "version": "3.1.0", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "@microsoft/logicappsux", - "version": "3.0.0", + "version": "3.1.0", "hasInstallScript": true, "license": "MIT", "dependencies": {