Pass existing integration id to test_connection (#4131)

# What this PR does

Pass existing integration id to `test_connection` servicenow endpoint
This commit is contained in:
Rares Mardare 2024-04-02 15:43:55 +03:00 committed by GitHub
parent 9256fbd12c
commit c1766d9fc2
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 9 additions and 3 deletions

View file

@ -53,7 +53,7 @@ export const ServiceNowAuthSection: React.FC = observer(() => {
};
setIsAuthTestRunning(true);
const result = await AlertReceiveChannelHelper.testServiceNowAuthentication({ data });
const result = await AlertReceiveChannelHelper.testServiceNowAuthentication({ id: currentIntegration?.id, data });
setAuthTestResult(result);
setIsAuthTestRunning(false);
}

View file

@ -74,14 +74,20 @@ export class AlertReceiveChannelHelper {
}
static async testServiceNowAuthentication({
id,
data,
}: {
id: ApiSchemas['AlertReceiveChannel']['id'];
data: OmitReadonlyMembers<ApiSchemas['AlertReceiveChannelUpdate']>;
}) {
try {
const result = await onCallApi({ skipErrorHandling: false }).POST('/alert_receive_channels/test_connection/', {
const endpoint = id
? '/alert_receive_channels/{id}/test_connection/'
: '/alert_receive_channels/test_connection/';
const result = await onCallApi({ skipErrorHandling: false }).POST(endpoint, {
body: data as ApiSchemas['AlertReceiveChannelUpdate'],
params: {},
params: { path: { id } },
});
return result?.response.status === 200;
} catch (ex) {