diff --git a/backend/services/api-test/src/main/java/io/metersphere/api/parser/api/HarParserApiDefinition.java b/backend/services/api-test/src/main/java/io/metersphere/api/parser/api/HarParserApiDefinition.java index 37bfc01b96..6039ec85c6 100644 --- a/backend/services/api-test/src/main/java/io/metersphere/api/parser/api/HarParserApiDefinition.java +++ b/backend/services/api-test/src/main/java/io/metersphere/api/parser/api/HarParserApiDefinition.java @@ -100,12 +100,11 @@ public class HarParserApiDefinition extends HttpApiDefinitionImportAbstractParse if (CollectionUtils.isEmpty(importApi.getResponse())) { importApi.setResponse(savedApi.getResponse()); } else { - if (CollectionUtils.isEmpty(savedApi.getResponse())) { importApi.getResponse().getFirst().setDefaultFlag(true); } else { List existenceResponseList = savedApi.getResponse(); - for (HttpResponse importRsp : savedApi.getResponse()) { + for (HttpResponse importRsp : importApi.getResponse()) { boolean isExistence = false; for (HttpResponse existenceRsp : existenceResponseList) { if (StringUtils.equals(importRsp.getName(), existenceRsp.getName())) { @@ -120,6 +119,9 @@ public class HarParserApiDefinition extends HttpApiDefinitionImportAbstractParse existenceResponseList.add(importRsp); } } + if (CollectionUtils.isNotEmpty(existenceResponseList)) { + importApi.setResponse(existenceResponseList); + } } } diff --git a/backend/services/api-test/src/main/java/io/metersphere/api/parser/ms/HTTPSamplerConverter.java b/backend/services/api-test/src/main/java/io/metersphere/api/parser/ms/HTTPSamplerConverter.java index 46f508c1b6..236a3f77c3 100644 --- a/backend/services/api-test/src/main/java/io/metersphere/api/parser/ms/HTTPSamplerConverter.java +++ b/backend/services/api-test/src/main/java/io/metersphere/api/parser/ms/HTTPSamplerConverter.java @@ -112,7 +112,7 @@ public class HTTPSamplerConverter extends AbstractMsElementConverter samplerProxy.getBody().setRawBody(new RawBody() {{ this.setValue(v); }})); - } else if (StringUtils.isNotEmpty(bodyType) || ("POST".equalsIgnoreCase(source.getMethod()) && source.getArguments().getArgumentsAsMap().size() > 0)) { + } else if (StringUtils.isNotEmpty(bodyType) || (StringUtils.equalsAnyIgnoreCase(source.getMethod(), "POST", "PUT") && !source.getArguments().getArgumentsAsMap().isEmpty())) { samplerProxy.getBody().setBodyType(Body.BodyType.WWW_FORM.name()); List keyValues = new LinkedList<>(); source.getArguments().getArguments().forEach(params -> {