diff --git a/api-test/backend/src/main/java/io/metersphere/controller/scenario/ApiScenarioController.java b/api-test/backend/src/main/java/io/metersphere/controller/scenario/ApiScenarioController.java index 620c7a5647..2adfc3df41 100644 --- a/api-test/backend/src/main/java/io/metersphere/controller/scenario/ApiScenarioController.java +++ b/api-test/backend/src/main/java/io/metersphere/controller/scenario/ApiScenarioController.java @@ -191,8 +191,8 @@ public class ApiScenarioController { } @PostMapping("/scenario-env") - public ScenarioEnv getScenarioDefinition(@RequestBody ApiScenarioEnvRequest request) { - return apiAutomationService.getApiScenarioEnv(request.getDefinition()); + public ScenarioEnv getScenarioDefinition(@RequestBody byte[] request) { + return apiAutomationService.getApiScenarioEnv(request); } @GetMapping("/env-project-ids/{id}") 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 eec5987c3c..daa9c0e8d4 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 @@ -2111,7 +2111,8 @@ public class ApiScenarioService { return follows.stream().map(ApiScenarioFollow::getFollowId).distinct().collect(Collectors.toList()); } - public ScenarioEnv getApiScenarioEnv(String definition) { + public ScenarioEnv getApiScenarioEnv(byte[] request) { + String definition = new String(request, StandardCharsets.UTF_8); return apiScenarioEnvService.getApiScenarioEnv(definition); } @@ -2161,7 +2162,7 @@ public class ApiScenarioService { List strings = new LinkedList<>(); apiScenarios.forEach(item -> { if (StringUtils.isNotEmpty(item.getScenarioDefinition())) { - ScenarioEnv env = getApiScenarioEnv(item.getScenarioDefinition()); + ScenarioEnv env = apiScenarioEnvService.getApiScenarioEnv(item.getScenarioDefinition()); if (!strings.contains(item.getProjectId())) { strings.add(item.getProjectId()); } diff --git a/api-test/frontend/src/business/automation/scenario/EditApiScenario.vue b/api-test/frontend/src/business/automation/scenario/EditApiScenario.vue index fc4b9ff614..6ca4434a93 100644 --- a/api-test/frontend/src/business/automation/scenario/EditApiScenario.vue +++ b/api-test/frontend/src/business/automation/scenario/EditApiScenario.vue @@ -1963,7 +1963,9 @@ export default { }, getEnv(definition) { return new Promise((resolve) => { - getApiScenarioEnv({ definition: definition }).then((res) => { + const encoder = new TextEncoder(); + const bytes = encoder.encode(definition, 'utf-8'); + getApiScenarioEnv({ definition: bytes }).then((res) => { if (res.data) { this.projectIds = new Set(res.data.projectIds); this.projectIds.add(this.projectId);