diff --git a/openmetadata-ui/src/main/resources/ui/src/components/Auth/AuthProviders/AuthProvider.tsx b/openmetadata-ui/src/main/resources/ui/src/components/Auth/AuthProviders/AuthProvider.tsx index b354e43ba721..34a2868d6841 100644 --- a/openmetadata-ui/src/main/resources/ui/src/components/Auth/AuthProviders/AuthProvider.tsx +++ b/openmetadata-ui/src/main/resources/ui/src/components/Auth/AuthProviders/AuthProvider.tsx @@ -479,6 +479,10 @@ export const AuthProvider = ({ } } + if (config.method === 'patch' && config.headers) { + config.headers['Content-type'] = 'application/json-patch+json'; + } + return withDomainFilter(config); }); diff --git a/openmetadata-ui/src/main/resources/ui/src/constants/constants.ts b/openmetadata-ui/src/main/resources/ui/src/constants/constants.ts index 15ad592d9f5b..0f199f059fa9 100644 --- a/openmetadata-ui/src/main/resources/ui/src/constants/constants.ts +++ b/openmetadata-ui/src/main/resources/ui/src/constants/constants.ts @@ -780,10 +780,6 @@ export const getKpiPath = (kpiName: string) => { return path; }; -export const configOptions = { - headers: { 'Content-type': 'application/json-patch+json' }, -}; - export const NOTIFICATION_READ_TIMER = 2500; export const TIER_CATEGORY = 'Tier'; @@ -843,3 +839,7 @@ export const ICON_DIMENSION = { export const COMMON_ICON_STYLES: CSSProperties = { verticalAlign: 'middle', }; + +export const APPLICATION_JSON_CONTENT_TYPE_HEADER = { + headers: { 'Content-type': 'application/json' }, +}; diff --git a/openmetadata-ui/src/main/resources/ui/src/rest/DocStoreAPI.ts b/openmetadata-ui/src/main/resources/ui/src/rest/DocStoreAPI.ts index 4ddcb5d78e0f..6d1c3d1c5fc2 100644 --- a/openmetadata-ui/src/main/resources/ui/src/rest/DocStoreAPI.ts +++ b/openmetadata-ui/src/main/resources/ui/src/rest/DocStoreAPI.ts @@ -49,13 +49,10 @@ export const createDocument = async (data: CreateDocument) => { }; export const updateDocument = async (id: string, data: Operation[]) => { - const configOptions = { - headers: { 'Content-type': 'application/json-patch+json' }, - }; const response = await axiosClient.patch< Operation[], AxiosResponse - >(`${BASE_URL}/${id}`, data, configOptions); + >(`${BASE_URL}/${id}`, data); return response.data; }; diff --git a/openmetadata-ui/src/main/resources/ui/src/rest/KpiAPI.ts b/openmetadata-ui/src/main/resources/ui/src/rest/KpiAPI.ts index c0d504acba69..f3e1c3348f49 100644 --- a/openmetadata-ui/src/main/resources/ui/src/rest/KpiAPI.ts +++ b/openmetadata-ui/src/main/resources/ui/src/rest/KpiAPI.ts @@ -51,14 +51,9 @@ export const putKPI = async (data: CreateKpiRequest) => { }; export const patchKPI = async (id: string, data: Operation[]) => { - const configOptions = { - headers: { 'Content-type': 'application/json-patch+json' }, - }; - const response = await APIClient.patch>( `/kpi/${id}`, - data, - configOptions + data ); return response.data; diff --git a/openmetadata-ui/src/main/resources/ui/src/rest/PersonaAPI.ts b/openmetadata-ui/src/main/resources/ui/src/rest/PersonaAPI.ts index 72a93f104d40..84e3baba90b5 100644 --- a/openmetadata-ui/src/main/resources/ui/src/rest/PersonaAPI.ts +++ b/openmetadata-ui/src/main/resources/ui/src/rest/PersonaAPI.ts @@ -58,13 +58,9 @@ export const createPersona = async (data: CreatePersona) => { }; export const updatePersona = async (id: string, data: Operation[]) => { - const configOptions = { - headers: { 'Content-type': 'application/json-patch+json' }, - }; const response = await axiosClient.patch>( `${BASE_URL}/${id}`, - data, - configOptions + data ); return response.data; diff --git a/openmetadata-ui/src/main/resources/ui/src/rest/SearchIndexAPI.ts b/openmetadata-ui/src/main/resources/ui/src/rest/SearchIndexAPI.ts index d2cf32ce9778..8b1bdfe2d83d 100644 --- a/openmetadata-ui/src/main/resources/ui/src/rest/SearchIndexAPI.ts +++ b/openmetadata-ui/src/main/resources/ui/src/rest/SearchIndexAPI.ts @@ -15,6 +15,7 @@ import { AxiosResponse } from 'axios'; import { Operation } from 'fast-json-patch'; import { PagingResponse, PagingWithoutTotal, RestoreRequestType } from 'Models'; import { QueryVote } from '../components/TableQueries/TableQueries.interface'; +import { APPLICATION_JSON_CONTENT_TYPE_HEADER } from '../constants/constants'; import { EntityReference, SearchIndex, @@ -64,14 +65,10 @@ export const patchSearchIndexDetails = async ( id: string, data: Operation[] ) => { - const configOptions = { - headers: { 'Content-type': 'application/json-patch+json' }, - }; - const response = await APIClient.patch< Operation[], AxiosResponse - >(`/searchIndexes/${id}`, data, configOptions); + >(`/searchIndexes/${id}`, data); return response.data; }; @@ -86,31 +83,30 @@ export const restoreSearchIndex = async (id: string) => { }; export const addFollower = async (searchIndexId: string, userId: string) => { - const configOptions = { - headers: { 'Content-type': 'application/json' }, - }; - const response = await APIClient.put< string, AxiosResponse<{ changeDescription: { fieldsAdded: { newValue: EntityReference[] }[] }; }> - >(`/searchIndexes/${searchIndexId}/followers`, userId, configOptions); + >( + `/searchIndexes/${searchIndexId}/followers`, + userId, + APPLICATION_JSON_CONTENT_TYPE_HEADER + ); return response.data; }; export const removeFollower = async (searchIndexId: string, userId: string) => { - const configOptions = { - headers: { 'Content-type': 'application/json' }, - }; - const response = await APIClient.delete< string, AxiosResponse<{ changeDescription: { fieldsDeleted: { oldValue: EntityReference[] }[] }; }> - >(`/searchIndexes/${searchIndexId}/followers/${userId}`, configOptions); + >( + `/searchIndexes/${searchIndexId}/followers/${userId}`, + APPLICATION_JSON_CONTENT_TYPE_HEADER + ); return response.data; }; diff --git a/openmetadata-ui/src/main/resources/ui/src/rest/applicationAPI.ts b/openmetadata-ui/src/main/resources/ui/src/rest/applicationAPI.ts index bd7c63fb60ed..8ad94e833d6f 100644 --- a/openmetadata-ui/src/main/resources/ui/src/rest/applicationAPI.ts +++ b/openmetadata-ui/src/main/resources/ui/src/rest/applicationAPI.ts @@ -86,14 +86,9 @@ export const uninstallApp = (appName: string, hardDelete = false) => { }; export const patchApplication = async (id: string, patch: Operation[]) => { - const configOptions = { - headers: { 'Content-type': 'application/json-patch+json' }, - }; - const response = await APIClient.patch>( `${BASE_URL}/${id}`, - patch, - configOptions + patch ); return response.data; diff --git a/openmetadata-ui/src/main/resources/ui/src/rest/chartAPI.ts b/openmetadata-ui/src/main/resources/ui/src/rest/chartAPI.ts index c67ab3d5901d..d25457b3a046 100644 --- a/openmetadata-ui/src/main/resources/ui/src/rest/chartAPI.ts +++ b/openmetadata-ui/src/main/resources/ui/src/rest/chartAPI.ts @@ -26,14 +26,9 @@ export const getChartById = async (id: string, params?: ListParams) => { }; export const updateChart = async (id: string, data: Operation[]) => { - const configOptions = { - headers: { 'Content-type': 'application/json-patch+json' }, - }; - const response = await APIClient.patch>( `/charts/${id}`, - data, - configOptions + data ); return response.data; diff --git a/openmetadata-ui/src/main/resources/ui/src/rest/dashboardAPI.ts b/openmetadata-ui/src/main/resources/ui/src/rest/dashboardAPI.ts index 0d28d79a3b23..67c1115d52ce 100644 --- a/openmetadata-ui/src/main/resources/ui/src/rest/dashboardAPI.ts +++ b/openmetadata-ui/src/main/resources/ui/src/rest/dashboardAPI.ts @@ -15,7 +15,10 @@ import { AxiosResponse } from 'axios'; import { Operation } from 'fast-json-patch'; import { PagingResponse, PagingWithoutTotal, RestoreRequestType } from 'Models'; import { QueryVote } from '../components/TableQueries/TableQueries.interface'; -import { PAGE_SIZE } from '../constants/constants'; +import { + APPLICATION_JSON_CONTENT_TYPE_HEADER, + PAGE_SIZE, +} from '../constants/constants'; import { Dashboard } from '../generated/entity/data/dashboard'; import { EntityHistory } from '../generated/type/entityHistory'; import { EntityReference } from '../generated/type/entityReference'; @@ -87,41 +90,35 @@ export const getDashboardByFqn = async (fqn: string, params?: ListParams) => { }; export const addFollower = async (dashboardID: string, userId: string) => { - const configOptions = { - headers: { 'Content-type': 'application/json' }, - }; - const response = await APIClient.put< string, AxiosResponse<{ changeDescription: { fieldsAdded: { newValue: EntityReference[] }[] }; }> - >(`${BASE_URL}/${dashboardID}/followers`, userId, configOptions); + >( + `${BASE_URL}/${dashboardID}/followers`, + userId, + APPLICATION_JSON_CONTENT_TYPE_HEADER + ); return response.data; }; export const removeFollower = async (dashboardID: string, userId: string) => { - const configOptions = { - headers: { 'Content-type': 'application/json' }, - }; - const response = await APIClient.delete<{ changeDescription: { fieldsDeleted: { oldValue: EntityReference[] }[] }; - }>(`${BASE_URL}/${dashboardID}/followers/${userId}`, configOptions); + }>( + `${BASE_URL}/${dashboardID}/followers/${userId}`, + APPLICATION_JSON_CONTENT_TYPE_HEADER + ); return response.data; }; export const patchDashboardDetails = async (id: string, data: Operation[]) => { - const configOptions = { - headers: { 'Content-type': 'application/json-patch+json' }, - }; - const response = await APIClient.patch>( `${BASE_URL}/${id}`, - data, - configOptions + data ); return response.data; diff --git a/openmetadata-ui/src/main/resources/ui/src/rest/dataModelsAPI.ts b/openmetadata-ui/src/main/resources/ui/src/rest/dataModelsAPI.ts index c5d29f4c5f8a..3a26eb58c70e 100644 --- a/openmetadata-ui/src/main/resources/ui/src/rest/dataModelsAPI.ts +++ b/openmetadata-ui/src/main/resources/ui/src/rest/dataModelsAPI.ts @@ -14,6 +14,7 @@ import { AxiosResponse } from 'axios'; import { Operation } from 'fast-json-patch'; import { RestoreRequestType } from 'Models'; import { QueryVote } from '../components/TableQueries/TableQueries.interface'; +import { APPLICATION_JSON_CONTENT_TYPE_HEADER } from '../constants/constants'; import { DashboardDataModel } from '../generated/entity/data/dashboardDataModel'; import { EntityHistory } from '../generated/type/entityHistory'; import { EntityReference } from '../generated/type/entityReference'; @@ -24,14 +25,6 @@ import APIClient from './index'; const URL = '/dashboard/datamodels'; -const configOptionsForPatch = { - headers: { 'Content-type': 'application/json-patch+json' }, -}; - -const configOptions = { - headers: { 'Content-type': 'application/json' }, -}; - export const getDataModelByFqn = async (fqn: string, params?: ListParams) => { const response = await APIClient.get( `${URL}/name/${getEncodedFqn(fqn)}`, @@ -50,7 +43,7 @@ export const patchDataModelDetails = async (id: string, data: Operation[]) => { const response = await APIClient.patch< Operation[], AxiosResponse - >(`${URL}/${id}`, data, configOptionsForPatch); + >(`${URL}/${id}`, data); return response.data; }; @@ -61,7 +54,7 @@ export const addDataModelFollower = async (id: string, userId: string) => { AxiosResponse<{ changeDescription: { fieldsAdded: { newValue: EntityReference[] }[] }; }> - >(`${URL}/${id}/followers`, userId, configOptions); + >(`${URL}/${id}/followers`, userId, APPLICATION_JSON_CONTENT_TYPE_HEADER); return response.data; }; @@ -72,7 +65,7 @@ export const removeDataModelFollower = async (id: string, userId: string) => { AxiosResponse<{ changeDescription: { fieldsDeleted: { oldValue: EntityReference[] }[] }; }> - >(`${URL}/${id}/followers/${userId}`, configOptions); + >(`${URL}/${id}/followers/${userId}`, APPLICATION_JSON_CONTENT_TYPE_HEADER); return response.data; }; diff --git a/openmetadata-ui/src/main/resources/ui/src/rest/dataProductAPI.ts b/openmetadata-ui/src/main/resources/ui/src/rest/dataProductAPI.ts index 5cc938d7cc96..1e20bf270cf8 100644 --- a/openmetadata-ui/src/main/resources/ui/src/rest/dataProductAPI.ts +++ b/openmetadata-ui/src/main/resources/ui/src/rest/dataProductAPI.ts @@ -51,14 +51,10 @@ export const addDataProducts = async (data: CreateDataProduct) => { }; export const patchDataProduct = async (id: string, patch: Operation[]) => { - const configOptions = { - headers: { 'Content-type': 'application/json-patch+json' }, - }; - const response = await APIClient.patch< Operation[], AxiosResponse - >(`${BASE_URL}/${id}`, patch, configOptions); + >(`${BASE_URL}/${id}`, patch); return response.data; }; diff --git a/openmetadata-ui/src/main/resources/ui/src/rest/databaseAPI.ts b/openmetadata-ui/src/main/resources/ui/src/rest/databaseAPI.ts index b4ed5ecc6411..c51b57f3cbc3 100644 --- a/openmetadata-ui/src/main/resources/ui/src/rest/databaseAPI.ts +++ b/openmetadata-ui/src/main/resources/ui/src/rest/databaseAPI.ts @@ -70,14 +70,9 @@ export const getDatabaseDetailsByFQN = async ( }; export const patchDatabaseDetails = async (id: string, data: Operation[]) => { - const configOptions = { - headers: { 'Content-type': 'application/json-patch+json' }, - }; - const response = await APIClient.patch>( `/databases/${id}`, - data, - configOptions + data ); return response.data; @@ -87,14 +82,10 @@ export const patchDatabaseSchemaDetails = async ( id: string, data: Operation[] ) => { - const configOptions = { - headers: { 'Content-type': 'application/json-patch+json' }, - }; - const response = await APIClient.patch< Operation[], AxiosResponse - >(`/databaseSchemas/${id}`, data, configOptions); + >(`/databaseSchemas/${id}`, data); return response.data; }; diff --git a/openmetadata-ui/src/main/resources/ui/src/rest/domainAPI.ts b/openmetadata-ui/src/main/resources/ui/src/rest/domainAPI.ts index 63bc0d72be90..ab5517588499 100644 --- a/openmetadata-ui/src/main/resources/ui/src/rest/domainAPI.ts +++ b/openmetadata-ui/src/main/resources/ui/src/rest/domainAPI.ts @@ -41,14 +41,9 @@ export const addDomains = async (data: CreateDomain) => { }; export const patchDomains = async (id: string, patch: Operation[]) => { - const configOptions = { - headers: { 'Content-type': 'application/json-patch+json' }, - }; - const response = await APIClient.patch>( `/domains/${id}`, - patch, - configOptions + patch ); return response.data; diff --git a/openmetadata-ui/src/main/resources/ui/src/rest/feedsAPI.ts b/openmetadata-ui/src/main/resources/ui/src/rest/feedsAPI.ts index 3c99beafdf66..e3033a29e06a 100644 --- a/openmetadata-ui/src/main/resources/ui/src/rest/feedsAPI.ts +++ b/openmetadata-ui/src/main/resources/ui/src/rest/feedsAPI.ts @@ -14,7 +14,6 @@ import { AxiosResponse } from 'axios'; import { Operation } from 'fast-json-patch'; import { isUndefined } from 'lodash'; -import { configOptions } from '../constants/constants'; import { TaskOperation } from '../constants/Feeds.constants'; import { FeedFilter } from '../enums/mydata.enum'; import { CloseTask } from '../generated/api/feed/closeTask'; @@ -133,8 +132,7 @@ export const deletePostById = (threadId: string, postId: string) => { export const updateThread = async (threadId: string, data: Operation[]) => { const response = await APIClient.patch>( `/feed/${threadId}`, - data, - configOptions + data ); return response.data; @@ -147,8 +145,7 @@ export const updatePost = async ( ) => { const response = await APIClient.patch>( `/feed/${threadId}/posts/${postId}`, - data, - configOptions + data ); return response.data; diff --git a/openmetadata-ui/src/main/resources/ui/src/rest/glossaryAPI.ts b/openmetadata-ui/src/main/resources/ui/src/rest/glossaryAPI.ts index 77a734b3805b..2f1dd095e3b3 100644 --- a/openmetadata-ui/src/main/resources/ui/src/rest/glossaryAPI.ts +++ b/openmetadata-ui/src/main/resources/ui/src/rest/glossaryAPI.ts @@ -62,14 +62,9 @@ export const updateGlossaries = ( }; export const patchGlossaries = async (id: string, patch: Operation[]) => { - const configOptions = { - headers: { 'Content-type': 'application/json-patch+json' }, - }; - const response = await APIClient.patch>( `/glossaries/${id}`, - patch, - configOptions + patch ); return response.data; @@ -131,14 +126,10 @@ export const addGlossaryTerm = ( }; export const patchGlossaryTerm = async (id: string, patch: Operation[]) => { - const configOptions = { - headers: { 'Content-type': 'application/json-patch+json' }, - }; - const response = await APIClient.patch< Operation[], AxiosResponse - >(`/glossaryTerms/${id}`, patch, configOptions); + >(`/glossaryTerms/${id}`, patch); return response.data; }; diff --git a/openmetadata-ui/src/main/resources/ui/src/rest/incidentManagerAPI.ts b/openmetadata-ui/src/main/resources/ui/src/rest/incidentManagerAPI.ts index e835e71737ef..2ebff5041cce 100644 --- a/openmetadata-ui/src/main/resources/ui/src/rest/incidentManagerAPI.ts +++ b/openmetadata-ui/src/main/resources/ui/src/rest/incidentManagerAPI.ts @@ -67,14 +67,10 @@ export const updateTestCaseIncidentById = async ( id: string, data: Operation[] ) => { - const configOptions = { - headers: { 'Content-type': 'application/json-patch+json' }, - }; - const response = await APIClient.patch< Operation[], AxiosResponse - >(`${testCaseIncidentUrl}/${id}`, data, configOptions); + >(`${testCaseIncidentUrl}/${id}`, data); return response.data; }; diff --git a/openmetadata-ui/src/main/resources/ui/src/rest/ingestionPipelineAPI.ts b/openmetadata-ui/src/main/resources/ui/src/rest/ingestionPipelineAPI.ts index 255b62a700a5..adb68c8ae6eb 100644 --- a/openmetadata-ui/src/main/resources/ui/src/rest/ingestionPipelineAPI.ts +++ b/openmetadata-ui/src/main/resources/ui/src/rest/ingestionPipelineAPI.ts @@ -126,14 +126,10 @@ export const updateIngestionPipeline = async ( }; export const patchIngestionPipeline = async (id: string, data: Operation[]) => { - const configOptions = { - headers: { 'Content-type': 'application/json-patch+json' }, - }; - const response = await APIClient.patch< Operation[], AxiosResponse - >(`/services/ingestionPipelines/${id}`, data, configOptions); + >(`/services/ingestionPipelines/${id}`, data); return response.data; }; diff --git a/openmetadata-ui/src/main/resources/ui/src/rest/metadataTypeAPI.ts b/openmetadata-ui/src/main/resources/ui/src/rest/metadataTypeAPI.ts index 46fceca4bd36..bd5c91d85f2b 100644 --- a/openmetadata-ui/src/main/resources/ui/src/rest/metadataTypeAPI.ts +++ b/openmetadata-ui/src/main/resources/ui/src/rest/metadataTypeAPI.ts @@ -55,15 +55,11 @@ export const addPropertyToEntity = async ( }; export const updateType = async (entityTypeId: string, data: Operation[]) => { - const configOptions = { - headers: { 'Content-type': 'application/json-patch+json' }, - }; const path = `/metadata/types/${entityTypeId}`; const response = await APIClient.patch>( path, - data, - configOptions + data ); return response.data; diff --git a/openmetadata-ui/src/main/resources/ui/src/rest/mlModelAPI.ts b/openmetadata-ui/src/main/resources/ui/src/rest/mlModelAPI.ts index f501ea440915..8ba909c4a244 100644 --- a/openmetadata-ui/src/main/resources/ui/src/rest/mlModelAPI.ts +++ b/openmetadata-ui/src/main/resources/ui/src/rest/mlModelAPI.ts @@ -15,6 +15,7 @@ import { AxiosResponse } from 'axios'; import { Operation } from 'fast-json-patch'; import { PagingWithoutTotal, RestoreRequestType } from 'Models'; import { QueryVote } from '../components/TableQueries/TableQueries.interface'; +import { APPLICATION_JSON_CONTENT_TYPE_HEADER } from '../constants/constants'; import { Mlmodel } from '../generated/entity/data/mlmodel'; import { EntityHistory } from '../generated/type/entityHistory'; import { EntityReference } from '../generated/type/entityReference'; @@ -76,45 +77,39 @@ export const getMlModels = async ( }; export const patchMlModelDetails = async (id: string, data: Operation[]) => { - const configOptions = { - headers: { 'Content-type': 'application/json-patch+json' }, - }; - const response = await APIClient.patch>( `${BASE_URL}/${id}`, - data, - configOptions + data ); return response.data; }; export const addFollower = async (mlModelId: string, userId: string) => { - const configOptions = { - headers: { 'Content-type': 'application/json' }, - }; - const response = await APIClient.put< string, AxiosResponse<{ changeDescription: { fieldsAdded: { newValue: EntityReference[] }[] }; }> - >(`${BASE_URL}/${mlModelId}/followers`, userId, configOptions); + >( + `${BASE_URL}/${mlModelId}/followers`, + userId, + APPLICATION_JSON_CONTENT_TYPE_HEADER + ); return response.data; }; export const removeFollower = async (mlModelId: string, userId: string) => { - const configOptions = { - headers: { 'Content-type': 'application/json' }, - }; - const response = await APIClient.delete< string, AxiosResponse<{ changeDescription: { fieldsDeleted: { oldValue: EntityReference[] }[] }; }> - >(`${BASE_URL}/${mlModelId}/followers/${userId}`, configOptions); + >( + `${BASE_URL}/${mlModelId}/followers/${userId}`, + APPLICATION_JSON_CONTENT_TYPE_HEADER + ); return response.data; }; diff --git a/openmetadata-ui/src/main/resources/ui/src/rest/pipelineAPI.ts b/openmetadata-ui/src/main/resources/ui/src/rest/pipelineAPI.ts index 721e080a0353..feb0a6935baa 100644 --- a/openmetadata-ui/src/main/resources/ui/src/rest/pipelineAPI.ts +++ b/openmetadata-ui/src/main/resources/ui/src/rest/pipelineAPI.ts @@ -15,6 +15,7 @@ import { AxiosResponse } from 'axios'; import { Operation } from 'fast-json-patch'; import { PagingResponse, PagingWithoutTotal, RestoreRequestType } from 'Models'; import { QueryVote } from '../components/TableQueries/TableQueries.interface'; +import { APPLICATION_JSON_CONTENT_TYPE_HEADER } from '../constants/constants'; import { Pipeline, PipelineStatus } from '../generated/entity/data/pipeline'; import { EntityHistory } from '../generated/type/entityHistory'; import { EntityReference } from '../generated/type/entityReference'; @@ -76,44 +77,38 @@ export const getPipelineByFqn = async (fqn: string, params?: ListParams) => { }; export const addFollower = async (pipelineID: string, userId: string) => { - const configOptions = { - headers: { 'Content-type': 'application/json' }, - }; - const response = await APIClient.put< string, AxiosResponse<{ changeDescription: { fieldsAdded: { newValue: EntityReference[] }[] }; }> - >(`${BASE_URL}/${pipelineID}/followers`, userId, configOptions); + >( + `${BASE_URL}/${pipelineID}/followers`, + userId, + APPLICATION_JSON_CONTENT_TYPE_HEADER + ); return response.data; }; export const removeFollower = async (pipelineID: string, userId: string) => { - const configOptions = { - headers: { 'Content-type': 'application/json' }, - }; - const response = await APIClient.delete< string, AxiosResponse<{ changeDescription: { fieldsDeleted: { oldValue: EntityReference[] }[] }; }> - >(`${BASE_URL}/${pipelineID}/followers/${userId}`, configOptions); + >( + `${BASE_URL}/${pipelineID}/followers/${userId}`, + APPLICATION_JSON_CONTENT_TYPE_HEADER + ); return response.data; }; export const patchPipelineDetails = async (id: string, data: Operation[]) => { - const configOptions = { - headers: { 'Content-type': 'application/json-patch+json' }, - }; - const response = await APIClient.patch>( `${BASE_URL}/${id}`, - data, - configOptions + data ); return response.data; diff --git a/openmetadata-ui/src/main/resources/ui/src/rest/queryAPI.ts b/openmetadata-ui/src/main/resources/ui/src/rest/queryAPI.ts index 18389eb0f65b..46a09134b951 100644 --- a/openmetadata-ui/src/main/resources/ui/src/rest/queryAPI.ts +++ b/openmetadata-ui/src/main/resources/ui/src/rest/queryAPI.ts @@ -62,14 +62,9 @@ export const postQuery = async (query: CreateQuery) => { return response.data; }; export const patchQueries = async (id: string, patch: Operation[]) => { - const configOptions = { - headers: { 'Content-type': 'application/json-patch+json' }, - }; - const response = await APIClient.patch>( `${BASE_URL}/${id}`, - patch, - configOptions + patch ); return response.data; diff --git a/openmetadata-ui/src/main/resources/ui/src/rest/serviceAPI.ts b/openmetadata-ui/src/main/resources/ui/src/rest/serviceAPI.ts index 20c07eadddb0..97943250bb36 100644 --- a/openmetadata-ui/src/main/resources/ui/src/rest/serviceAPI.ts +++ b/openmetadata-ui/src/main/resources/ui/src/rest/serviceAPI.ts @@ -19,7 +19,7 @@ import { ServicesUpdateRequest, } from 'Models'; import { WILD_CARD_CHAR } from '../constants/char.constants'; -import { configOptions, PAGE_SIZE } from '../constants/constants'; +import { PAGE_SIZE } from '../constants/constants'; import { SearchIndex } from '../enums/search.enum'; import { EntityHistory } from '../generated/type/entityHistory'; import { Include } from '../generated/type/include'; @@ -138,7 +138,7 @@ export const patchService = async ( const response = await APIClient.patch< ServicesUpdateRequest, AxiosResponse - >(`/services/${serviceCat}/${id}`, options, configOptions); + >(`/services/${serviceCat}/${id}`, options); return response.data; }; @@ -151,7 +151,7 @@ export const patchDomainSupportedService = async ( const response = await APIClient.patch< ServicesUpdateRequest, AxiosResponse - >(`/services/${serviceCat}/${id}`, options, configOptions); + >(`/services/${serviceCat}/${id}`, options); return response.data; }; diff --git a/openmetadata-ui/src/main/resources/ui/src/rest/settingConfigAPI.ts b/openmetadata-ui/src/main/resources/ui/src/rest/settingConfigAPI.ts index 6eef609d719b..e23e6a8f4eed 100644 --- a/openmetadata-ui/src/main/resources/ui/src/rest/settingConfigAPI.ts +++ b/openmetadata-ui/src/main/resources/ui/src/rest/settingConfigAPI.ts @@ -13,6 +13,7 @@ import { AxiosResponse } from 'axios'; import axiosClient from '.'; +import { APPLICATION_JSON_CONTENT_TYPE_HEADER } from '../constants/constants'; import { LoginConfiguration } from '../generated/configuration/loginConfiguration'; import { LogoConfiguration } from '../generated/configuration/logoConfiguration'; import { Settings, SettingType } from '../generated/settings/settings'; @@ -50,14 +51,10 @@ export const getLoginConfig = async () => { }; export const testEmailConnection = async (email: string) => { - const configOptions = { - headers: { 'Content-type': 'application/json' }, - }; - const response = await axiosClient.put( '/system/email/test', email, - configOptions + APPLICATION_JSON_CONTENT_TYPE_HEADER ); return response; diff --git a/openmetadata-ui/src/main/resources/ui/src/rest/storageAPI.ts b/openmetadata-ui/src/main/resources/ui/src/rest/storageAPI.ts index e23c3958536e..2de6b80e9f2a 100644 --- a/openmetadata-ui/src/main/resources/ui/src/rest/storageAPI.ts +++ b/openmetadata-ui/src/main/resources/ui/src/rest/storageAPI.ts @@ -14,6 +14,7 @@ import { AxiosResponse } from 'axios'; import { Operation } from 'fast-json-patch'; import { PagingWithoutTotal, RestoreRequestType } from 'Models'; import { QueryVote } from '../components/TableQueries/TableQueries.interface'; +import { APPLICATION_JSON_CONTENT_TYPE_HEADER } from '../constants/constants'; import { Container } from '../generated/entity/data/container'; import { EntityHistory } from '../generated/type/entityHistory'; import { EntityReference } from '../generated/type/entityReference'; @@ -24,14 +25,6 @@ import { ServicePageData } from '../pages/ServiceDetailsPage/ServiceDetailsPage' import { getEncodedFqn } from '../utils/StringsUtils'; import APIClient from './index'; -const configOptionsForPatch = { - headers: { 'Content-type': 'application/json-patch+json' }, -}; - -const configOptions = { - headers: { 'Content-type': 'application/json' }, -}; - const BASE_URL = '/containers'; export const getContainers = async (args: { @@ -73,8 +66,7 @@ export const getContainerByName = async (name: string, params?: ListParams) => { export const patchContainerDetails = async (id: string, data: Operation[]) => { const response = await APIClient.patch>( `${BASE_URL}/${id}`, - data, - configOptionsForPatch + data ); return response.data; @@ -86,7 +78,11 @@ export const addContainerFollower = async (id: string, userId: string) => { AxiosResponse<{ changeDescription: { fieldsAdded: { newValue: EntityReference[] }[] }; }> - >(`${BASE_URL}/${id}/followers`, userId, configOptions); + >( + `${BASE_URL}/${id}/followers`, + userId, + APPLICATION_JSON_CONTENT_TYPE_HEADER + ); return response.data; }; @@ -106,7 +102,10 @@ export const removeContainerFollower = async (id: string, userId: string) => { AxiosResponse<{ changeDescription: { fieldsDeleted: { oldValue: EntityReference[] }[] }; }> - >(`${BASE_URL}/${id}/followers/${userId}`, configOptions); + >( + `${BASE_URL}/${id}/followers/${userId}`, + APPLICATION_JSON_CONTENT_TYPE_HEADER + ); return response.data; }; diff --git a/openmetadata-ui/src/main/resources/ui/src/rest/storedProceduresAPI.ts b/openmetadata-ui/src/main/resources/ui/src/rest/storedProceduresAPI.ts index 8f6ec9a69a18..ec09651efecf 100644 --- a/openmetadata-ui/src/main/resources/ui/src/rest/storedProceduresAPI.ts +++ b/openmetadata-ui/src/main/resources/ui/src/rest/storedProceduresAPI.ts @@ -14,6 +14,7 @@ import { AxiosResponse } from 'axios'; import { Operation } from 'fast-json-patch'; import { PagingResponse, RestoreRequestType } from 'Models'; import { QueryVote } from '../components/TableQueries/TableQueries.interface'; +import { APPLICATION_JSON_CONTENT_TYPE_HEADER } from '../constants/constants'; import { StoredProcedure } from '../generated/entity/data/storedProcedure'; import { EntityHistory } from '../generated/type/entityHistory'; import { EntityReference } from '../generated/type/entityReference'; @@ -34,14 +35,6 @@ export interface ListStoredProcedureParams { const URL = '/storedProcedures'; -const configOptionsForPatch = { - headers: { 'Content-type': 'application/json-patch+json' }, -}; - -const configOptions = { - headers: { 'Content-type': 'application/json' }, -}; - export const getStoredProceduresList = async ( params?: ListStoredProcedureParams ) => { @@ -76,7 +69,7 @@ export const patchStoredProceduresDetails = async ( const response = await APIClient.patch< Operation[], AxiosResponse - >(`${URL}/${id}`, data, configOptionsForPatch); + >(`${URL}/${id}`, data); return response.data; }; @@ -90,7 +83,7 @@ export const addStoredProceduresFollower = async ( AxiosResponse<{ changeDescription: { fieldsAdded: { newValue: EntityReference[] }[] }; }> - >(`${URL}/${id}/followers`, userId, configOptions); + >(`${URL}/${id}/followers`, userId, APPLICATION_JSON_CONTENT_TYPE_HEADER); return response.data; }; @@ -104,7 +97,7 @@ export const removeStoredProceduresFollower = async ( AxiosResponse<{ changeDescription: { fieldsDeleted: { oldValue: EntityReference[] }[] }; }> - >(`${URL}/${id}/followers/${userId}`, configOptions); + >(`${URL}/${id}/followers/${userId}`, APPLICATION_JSON_CONTENT_TYPE_HEADER); return response.data; }; diff --git a/openmetadata-ui/src/main/resources/ui/src/rest/tableAPI.ts b/openmetadata-ui/src/main/resources/ui/src/rest/tableAPI.ts index c0683bce5c7d..132a6bf025d7 100644 --- a/openmetadata-ui/src/main/resources/ui/src/rest/tableAPI.ts +++ b/openmetadata-ui/src/main/resources/ui/src/rest/tableAPI.ts @@ -15,6 +15,7 @@ import { AxiosResponse } from 'axios'; import { Operation } from 'fast-json-patch'; import { PagingResponse, RestoreRequestType } from 'Models'; import { QueryVote } from '../components/TableQueries/TableQueries.interface'; +import { APPLICATION_JSON_CONTENT_TYPE_HEADER } from '../constants/constants'; import { SystemProfile } from '../generated/api/data/createTableProfile'; import { ColumnProfile, @@ -74,14 +75,9 @@ export const getTableDetailsByFQN = async ( }; export const patchTableDetails = async (id: string, data: Operation[]) => { - const configOptions = { - headers: { 'Content-type': 'application/json-patch+json' }, - }; - const response = await APIClient.patch>( `${BASE_URL}/${id}`, - data, - configOptions + data ); return response.data; @@ -97,31 +93,30 @@ export const restoreTable = async (id: string) => { }; export const addFollower = async (tableId: string, userId: string) => { - const configOptions = { - headers: { 'Content-type': 'application/json' }, - }; - const response = await APIClient.put< string, AxiosResponse<{ changeDescription: { fieldsAdded: { newValue: EntityReference[] }[] }; }> - >(`${BASE_URL}/${tableId}/followers`, userId, configOptions); + >( + `${BASE_URL}/${tableId}/followers`, + userId, + APPLICATION_JSON_CONTENT_TYPE_HEADER + ); return response.data; }; export const removeFollower = async (tableId: string, userId: string) => { - const configOptions = { - headers: { 'Content-type': 'application/json' }, - }; - const response = await APIClient.delete< string, AxiosResponse<{ changeDescription: { fieldsDeleted: { oldValue: EntityReference[] }[] }; }> - >(`${BASE_URL}/${tableId}/followers/${userId}`, configOptions); + >( + `${BASE_URL}/${tableId}/followers/${userId}`, + APPLICATION_JSON_CONTENT_TYPE_HEADER + ); return response.data; }; @@ -138,14 +133,14 @@ export const putTableProfileConfig = async ( tableId: string, data: TableProfilerConfig ) => { - const configOptions = { - headers: { 'Content-type': 'application/json' }, - }; - const response = await APIClient.put< TableProfilerConfig, AxiosResponse - >(`${BASE_URL}/${tableId}/tableProfilerConfig`, data, configOptions); + >( + `${BASE_URL}/${tableId}/tableProfilerConfig`, + data, + APPLICATION_JSON_CONTENT_TYPE_HEADER + ); return response.data; }; diff --git a/openmetadata-ui/src/main/resources/ui/src/rest/tagAPI.ts b/openmetadata-ui/src/main/resources/ui/src/rest/tagAPI.ts index 690fe9d2232f..b4e22b0c6ed3 100644 --- a/openmetadata-ui/src/main/resources/ui/src/rest/tagAPI.ts +++ b/openmetadata-ui/src/main/resources/ui/src/rest/tagAPI.ts @@ -93,13 +93,10 @@ export const updateClassification = async (data: Classification) => { return response.data; }; export const patchClassification = async (id: string, data: Operation[]) => { - const configOptions = { - headers: { 'Content-type': 'application/json-patch+json' }, - }; const response = await APIClient.patch< Operation[], AxiosResponse - >(`${BASE_URL}/${id}`, data, configOptions); + >(`${BASE_URL}/${id}`, data); return response.data; }; @@ -128,13 +125,9 @@ export const updateTag = async (data: Classification) => { }; export const patchTag = async (id: string, data: Operation[]) => { - const configOptions = { - headers: { 'Content-type': 'application/json-patch+json' }, - }; const response = await APIClient.patch>( `/tags/${id}`, - data, - configOptions + data ); return response.data; diff --git a/openmetadata-ui/src/main/resources/ui/src/rest/teamsAPI.ts b/openmetadata-ui/src/main/resources/ui/src/rest/teamsAPI.ts index 2250a7ac59f4..1bece6f853a5 100644 --- a/openmetadata-ui/src/main/resources/ui/src/rest/teamsAPI.ts +++ b/openmetadata-ui/src/main/resources/ui/src/rest/teamsAPI.ts @@ -66,14 +66,9 @@ export const createTeam = async (data: CreateTeam) => { }; export const patchTeamDetail = async (id: string, data: Operation[]) => { - const configOptions = { - headers: { 'Content-type': 'application/json-patch+json' }, - }; - const response = await APIClient.patch>( `/teams/${id}`, - data, - configOptions + data ); return response.data; diff --git a/openmetadata-ui/src/main/resources/ui/src/rest/testAPI.ts b/openmetadata-ui/src/main/resources/ui/src/rest/testAPI.ts index a2459fb4592c..e977bfea304d 100644 --- a/openmetadata-ui/src/main/resources/ui/src/rest/testAPI.ts +++ b/openmetadata-ui/src/main/resources/ui/src/rest/testAPI.ts @@ -129,14 +129,9 @@ export const createTestCase = async (data: CreateTestCase) => { }; export const updateTestCaseById = async (id: string, data: Operation[]) => { - const configOptions = { - headers: { 'Content-type': 'application/json-patch+json' }, - }; - const response = await APIClient.patch>( `${testCaseUrl}/${id}`, - data, - configOptions + data ); return response.data; @@ -244,14 +239,9 @@ export const getTestSuiteByName = async ( }; export const updateTestSuiteById = async (id: string, data: Operation[]) => { - const configOptions = { - headers: { 'Content-type': 'application/json-patch+json' }, - }; - const response = await APIClient.patch>( `${testSuiteUrl}/${id}`, - data, - configOptions + data ); return response.data; @@ -277,13 +267,9 @@ export const patchTestCaseResult = async ({ timestamp: number; patch: Operation[]; }) => { - const configOptions = { - headers: { 'Content-type': 'application/json-patch+json' }, - }; const response = await APIClient.patch>( `${testCaseUrl}/${getEncodedFqn(testCaseFqn)}/testCaseResult/${timestamp}`, - patch, - configOptions + patch ); return response.data; diff --git a/openmetadata-ui/src/main/resources/ui/src/rest/topicsAPI.ts b/openmetadata-ui/src/main/resources/ui/src/rest/topicsAPI.ts index 7c1d16f6a8f8..876314a5c8c0 100644 --- a/openmetadata-ui/src/main/resources/ui/src/rest/topicsAPI.ts +++ b/openmetadata-ui/src/main/resources/ui/src/rest/topicsAPI.ts @@ -15,6 +15,7 @@ import { AxiosResponse } from 'axios'; import { Operation } from 'fast-json-patch'; import { PagingWithoutTotal, RestoreRequestType } from 'Models'; import { QueryVote } from '../components/TableQueries/TableQueries.interface'; +import { APPLICATION_JSON_CONTENT_TYPE_HEADER } from '../constants/constants'; import { Topic } from '../generated/entity/data/topic'; import { EntityHistory } from '../generated/type/entityHistory'; import { EntityReference } from '../generated/type/entityReference'; @@ -78,25 +79,21 @@ export const getTopicByFqn = async (fqn: string, params?: ListParams) => { }; export const addFollower = async (topicId: string, userId: string) => { - const configOptions = { - headers: { 'Content-type': 'application/json' }, - }; - const response = await APIClient.put< string, AxiosResponse<{ changeDescription: { fieldsAdded: { newValue: EntityReference[] }[] }; }> - >(`${BASE_URL}/${topicId}/followers`, userId, configOptions); + >( + `${BASE_URL}/${topicId}/followers`, + userId, + APPLICATION_JSON_CONTENT_TYPE_HEADER + ); return response.data; }; export const removeFollower = async (topicId: string, userId: string) => { - const configOptions = { - headers: { 'Content-type': 'application/json' }, - }; - const response = await APIClient.delete< string, AxiosResponse<{ @@ -104,20 +101,18 @@ export const removeFollower = async (topicId: string, userId: string) => { fieldsDeleted: { oldValue: EntityReference[] }[]; }; }> - >(`${BASE_URL}/${topicId}/followers/${userId}`, configOptions); + >( + `${BASE_URL}/${topicId}/followers/${userId}`, + APPLICATION_JSON_CONTENT_TYPE_HEADER + ); return response.data; }; export const patchTopicDetails = async (id: string, data: Operation[]) => { - const configOptions = { - headers: { 'Content-type': 'application/json-patch+json' }, - }; - const response = await APIClient.patch>( `${BASE_URL}/${id}`, - data, - configOptions + data ); return response.data; diff --git a/openmetadata-ui/src/main/resources/ui/src/rest/userAPI.ts b/openmetadata-ui/src/main/resources/ui/src/rest/userAPI.ts index a4b461a04f48..504efa7d2428 100644 --- a/openmetadata-ui/src/main/resources/ui/src/rest/userAPI.ts +++ b/openmetadata-ui/src/main/resources/ui/src/rest/userAPI.ts @@ -15,6 +15,7 @@ import { AxiosResponse } from 'axios'; import { Operation } from 'fast-json-patch'; import { PagingResponse } from 'Models'; +import { APPLICATION_JSON_CONTENT_TYPE_HEADER } from '../constants/constants'; import { SearchIndex } from '../enums/search.enum'; import { AuthenticationMechanism, @@ -51,14 +52,9 @@ export const getUsers = async (params: UsersQueryParams) => { }; export const updateUserDetail = async (id: string, data: Operation[]) => { - const configOptions = { - headers: { 'Content-type': 'application/json-patch+json' }, - }; - const response = await APIClient.patch>( `/users/${id}`, - data, - configOptions + data ); return response.data; @@ -145,9 +141,6 @@ export const getUserToken = async (id: string) => { }; export const generateUserToken = async (id: string, expiry: string) => { - const configOptions = { - headers: { 'Content-type': 'application/json' }, - }; const payload = { JWTTokenExpiry: expiry, }; @@ -155,7 +148,7 @@ export const generateUserToken = async (id: string, expiry: string) => { const response = await APIClient.put>( `/users/generateToken/${id}`, payload, - configOptions + APPLICATION_JSON_CONTENT_TYPE_HEADER ); return response.data; @@ -196,14 +189,9 @@ export const getBotByName = async (name: string, params?: ListParams) => { }; export const updateBotDetail = async (id: string, data: Operation[]) => { - const configOptions = { - headers: { 'Content-type': 'application/json-patch+json' }, - }; - const response = await APIClient.patch>( `/bots/${id}`, - data, - configOptions + data ); return response.data;