Repository: appsmithorg/appsmith
File: app/server/appsmith-plugins/restApiPlugin/src/main/java/com/external/plugins/RestApiPlugin.java (Java)

Code before:
                        AppsmithPluginError.PLUGIN_EXECUTE_ARGUMENT_ERROR,
                        RestApiErrorMessages.NO_HTTP_METHOD_ERROR_MSG));
                errorResult.setRequest(actionExecutionRequest);
                return Mono.just(errorResult);
            }

            final RequestCaptureFilter requestCaptureFilter = new RequestCaptureFilter(objectMapper);
            Object requestBodyObj =
                    dataUtils.getRequestBodyObject(actionConfiguration, reqContentType, encodeParamsToggle, httpMethod);
            WebClient client = restAPIActivateUtils.getWebClient(
                    webClientBuilder, apiConnection, reqContentType, EXCHANGE_STRATEGIES, requestCaptureFilter);

            /* Triggering the actual REST API call */
            return restAPIActivateUtils
                    .triggerApiCall(
                            client,
                            httpMethod,
                            uri,
                            requestBodyObj,
                            actionExecutionRequest,
                            objectMapper,
                            hintMessages,
                            errorResult,
                            requestCaptureFilter,
                            datasourceConfiguration)
                    .name(TRIGGER_API_CALL)
                    .tap(Micrometer.observation(observationRegistry))
                    .onErrorResume(error -> {
                        boolean isBodySentWithApiRequest = requestBodyObj == null ? false : true;
                        errorResult.setRequest(requestCaptureFilter.populateRequestFields(
                                actionExecutionRequest, isBodySentWithApiRequest, datasourceConfiguration));
                        errorResult.setIsExecutionSuccess(false);
                        log.debug(String.format(
                                "An error has occurred while trying to run the API query for url: %s, path: %s",
                                datasourceConfiguration.getUrl(), actionConfiguration.getPath()));
                        error.printStackTrace();
                        if (!(error instanceof AppsmithPluginException)) {
                            error = new AppsmithPluginException(
                                    RestApiPluginError.API_EXECUTION_FAILED,
                                    RestApiErrorMessages.API_EXECUTION_FAILED_ERROR_MSG,
                                    error);
                        }
                        errorResult.setErrorInfo(error);
                        return Mono.just(errorResult);
                    });
        }

        private ActionConfiguration updateActionConfigurationForPagination(
                ActionConfiguration actionConfiguration,
                List<Property> queryParamsList,
                PaginationField paginationField) {

Review comment (refactor):
Should we add this telemetry around this line : https://github.com/appsmithorg/appsmith-ee/blob/1d6cc67e6136be66e2ff824540524218729076b5/app/server/appsmith-interfaces/src/main/java/com/appsmith/external/helpers/restApiUtils/helpers/RestAPIActivateUtils.java#L179 instead ?

Code after:
                errorResult.setRequest(actionExecutionRequest);
                return Mono.just(errorResult);
            }

            final RequestCaptureFilter requestCaptureFilter = new RequestCaptureFilter(objectMapper);
            Object requestBodyObj =
                    dataUtils.getRequestBodyObject(actionConfiguration, reqContentType, encodeParamsToggle, httpMethod);
            WebClient client = restAPIActivateUtils.getWebClient(
                    webClientBuilder, apiConnection, reqContentType, EXCHANGE_STRATEGIES, requestCaptureFilter);

            /* Triggering the actual REST API call */
            return restAPIActivateUtils
                    .triggerApiCall(
                            client,
                            httpMethod,
                            uri,
                            requestBodyObj,
                            actionExecutionRequest,
                            objectMapper,
                            hintMessages,
                            errorResult,
                            requestCaptureFilter,
                            datasourceConfiguration,
                            observationRegistry)
                    .name(TRIGGER_API_CALL)
                    .tap(Micrometer.observation(observationRegistry))
                    .onErrorResume(error -> {
                        boolean isBodySentWithApiRequest = requestBodyObj == null ? false : true;
                        errorResult.setRequest(requestCaptureFilter.populateRequestFields(
                                actionExecutionRequest, isBodySentWithApiRequest, datasourceConfiguration));
                        errorResult.setIsExecutionSuccess(false);
                        log.debug(String.format(
                                "An error has occurred while trying to run the API query for url: %s, path: %s",
                                datasourceConfiguration.getUrl(), actionConfiguration.getPath()));
                        error.printStackTrace();
                        if (!(error instanceof AppsmithPluginException)) {
                            error = new AppsmithPluginException(
                                    RestApiPluginError.API_EXECUTION_FAILED,
                                    RestApiErrorMessages.API_EXECUTION_FAILED_ERROR_MSG,
                                    error);
                        }
                        errorResult.setErrorInfo(error);
                        return Mono.just(errorResult);
                    });
        }

        private ActionConfiguration updateActionConfigurationForPagination(
                ActionConfiguration actionConfiguration,
                List<Property> queryParamsList,
                PaginationField paginationField) {
            if (PaginationField.NEXT.equals(paginationField) || PaginationField.PREV.equals(paginationField)) {