diff --git a/api-test/backend/src/main/java/io/metersphere/api/exec/api/ApiExecuteService.java b/api-test/backend/src/main/java/io/metersphere/api/exec/api/ApiExecuteService.java index a80b91bdf0..05ddbe8e70 100644 --- a/api-test/backend/src/main/java/io/metersphere/api/exec/api/ApiExecuteService.java +++ b/api-test/backend/src/main/java/io/metersphere/api/exec/api/ApiExecuteService.java @@ -133,9 +133,6 @@ public class ApiExecuteService { : request.getReportId(), request.getRunMode(), null); if (testCase != null && StringUtils.isNotEmpty(testCase.getRequest())) { try { - HashTree jmeterHashTree = this.generateHashTree(request, testCase, runModeConfigDTO); - // 调用执行方法 - runRequest.setHashTree(jmeterHashTree); if (MapUtils.isNotEmpty(extendedParameters)) { runRequest.setExtendedParameters(extendedParameters); } diff --git a/api-test/backend/src/main/java/io/metersphere/service/scenario/ApiScenarioService.java b/api-test/backend/src/main/java/io/metersphere/service/scenario/ApiScenarioService.java index daa9c0e8d4..47649f6777 100644 --- a/api-test/backend/src/main/java/io/metersphere/service/scenario/ApiScenarioService.java +++ b/api-test/backend/src/main/java/io/metersphere/service/scenario/ApiScenarioService.java @@ -801,16 +801,20 @@ public class ApiScenarioService { public ParameterConfig getConfig(ApiScenarioDTO scenario) { try { + ParameterConfig config = new ParameterConfig(); Map environmentMap = new HashMap<>(); String environmentType = scenario.getEnvironmentType(); String environmentGroupId = scenario.getEnvironmentGroupId(); String environmentJson = scenario.getEnvironmentJson(); - if (StringUtils.equals(environmentType, EnvironmentType.GROUP.name())) { + if (StringUtils.equals(environmentType, EnvironmentType.GROUP.name()) + && StringUtils.isNotEmpty(environmentGroupId)) { environmentMap = environmentGroupProjectService.getEnvMap(environmentGroupId); - } else if (StringUtils.equals(environmentType, EnvironmentType.JSON.name())) { + } else if (StringUtils.equals(environmentType, EnvironmentType.JSON.name()) + && StringUtils.isNotEmpty(environmentJson)) { environmentMap = JSON.parseObject(environmentJson, Map.class); + } else { + return config; } - ParameterConfig config = new ParameterConfig(); apiScenarioEnvService.setEnvConfig(environmentMap, config); return config; } catch (Exception e) { diff --git a/api-test/frontend/src/api/scenario.js b/api-test/frontend/src/api/scenario.js index a12bf7e31b..8d80299dc2 100644 --- a/api-test/frontend/src/api/scenario.js +++ b/api-test/frontend/src/api/scenario.js @@ -103,8 +103,20 @@ export function listWithIds(params) { return post('/api/automation/list-blobs', params); } +export function getUploadConfig(url, formData) { + return { + method: 'POST', + url: url, + data: formData, + headers: { + 'Content-Type': "application/octet-stream", + }, + }; +} + export function getApiScenarioEnv(params) { - return post('/api/automation/scenario-env', params); + let reqParams = getUploadConfig('/api/automation/scenario-env', params); + return request( reqParams); } export function batchEditScenario(params) { diff --git a/api-test/frontend/src/business/automation/scenario/EditApiScenario.vue b/api-test/frontend/src/business/automation/scenario/EditApiScenario.vue index 6ca4434a93..cb0f41a7de 100644 --- a/api-test/frontend/src/business/automation/scenario/EditApiScenario.vue +++ b/api-test/frontend/src/business/automation/scenario/EditApiScenario.vue @@ -1965,7 +1965,7 @@ export default { return new Promise((resolve) => { const encoder = new TextEncoder(); const bytes = encoder.encode(definition, 'utf-8'); - getApiScenarioEnv({ definition: bytes }).then((res) => { + getApiScenarioEnv(bytes ).then((res) => { if (res.data) { this.projectIds = new Set(res.data.projectIds); this.projectIds.add(this.projectId);