diff --git a/backend/src/main/java/io/metersphere/api/dto/automation/parse/MsJmeterParser.java b/backend/src/main/java/io/metersphere/api/dto/automation/parse/MsJmeterParser.java index 0ce4456848..7cb52c524c 100644 --- a/backend/src/main/java/io/metersphere/api/dto/automation/parse/MsJmeterParser.java +++ b/backend/src/main/java/io/metersphere/api/dto/automation/parse/MsJmeterParser.java @@ -136,6 +136,8 @@ public class MsJmeterParser extends ApiImportAbstractParser { try { HTTPSamplerProxy source = (HTTPSamplerProxy) key; BeanUtils.copyBean(samplerProxy, source); + samplerProxy.setRest(new ArrayList(){{this.add(new KeyValue());}}); + samplerProxy.setArguments(new ArrayList(){{this.add(new KeyValue());}}); if (source != null && source.getHTTPFiles().length > 0) { samplerProxy.getBody().initBinary(); samplerProxy.getBody().setType(Body.FORM_DATA); @@ -153,12 +155,7 @@ public class MsJmeterParser extends ApiImportAbstractParser { keyValue.setFiles(files); keyValues.add(keyValue); } - if (source.getPostBodyRaw() && CollectionUtils.isNotEmpty(keyValues)) { - samplerProxy.getBody().setType(Body.RAW); - samplerProxy.getBody().setRaw(keyValues.get(0).getValue()); - } else { - samplerProxy.getBody().setKvs(keyValues); - } + samplerProxy.getBody().setKvs(keyValues); } samplerProxy.setProtocol(RequestType.HTTP); samplerProxy.setPort(source.getPort() + ""); @@ -168,6 +165,7 @@ public class MsJmeterParser extends ApiImportAbstractParser { source.getArguments().getArgumentsAsMap().forEach((k, v) -> { samplerProxy.getBody().setRaw(v); }); + samplerProxy.getBody().initKvs(); } else { List keyValues = new LinkedList<>(); source.getArguments().getArgumentsAsMap().forEach((k, v) -> { diff --git a/backend/src/main/java/io/metersphere/api/dto/scenario/Body.java b/backend/src/main/java/io/metersphere/api/dto/scenario/Body.java index cabfccc0c4..4ae0e7d279 100644 --- a/backend/src/main/java/io/metersphere/api/dto/scenario/Body.java +++ b/backend/src/main/java/io/metersphere/api/dto/scenario/Body.java @@ -66,12 +66,8 @@ public class Body { sampler.setDoMultipart(true); } } else { - if (!this.isJson()) { - sampler.setPostBodyRaw(true); - } else { - if (StringUtils.isNotEmpty(this.format) && "JSON-SCHEMA".equals(this.format) && this.getJsonSchema() != null) { - this.raw = JSONSchemaGenerator.getJson(com.alibaba.fastjson.JSON.toJSONString(this.getJsonSchema())); - } + if (StringUtils.isNotEmpty(this.format) && "JSON-SCHEMA".equals(this.format) && this.getJsonSchema() != null) { + this.raw = JSONSchemaGenerator.getJson(com.alibaba.fastjson.JSON.toJSONString(this.getJsonSchema())); } KeyValue keyValue = new KeyValue("", "JSON-SCHEMA", this.getRaw(), true, true); sampler.setPostBodyRaw(true);