diff --git a/backend/src/main/java/io/metersphere/api/dto/definition/parse/PostmanDefinitionParser.java b/backend/src/main/java/io/metersphere/api/dto/definition/parse/PostmanDefinitionParser.java index 3a96a1849b..7ed3c8ec2e 100644 --- a/backend/src/main/java/io/metersphere/api/dto/definition/parse/PostmanDefinitionParser.java +++ b/backend/src/main/java/io/metersphere/api/dto/definition/parse/PostmanDefinitionParser.java @@ -4,6 +4,7 @@ import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.parser.Feature; import io.metersphere.api.dto.ApiTestImportRequest; import io.metersphere.api.dto.definition.request.sampler.MsHTTPSamplerProxy; +import io.metersphere.api.dto.definition.response.HttpResponse; import io.metersphere.api.dto.parse.postman.PostmanCollection; import io.metersphere.api.dto.parse.postman.PostmanItem; import io.metersphere.api.dto.parse.postman.PostmanKeyValue; @@ -69,7 +70,7 @@ public class PostmanDefinitionParser extends PostmanAbstractParserParser extends ApiImportAbstractPa return request; } - protected MsHTTPSamplerProxy parsePostmanResponse(PostmanItem requestItem) { + protected HttpResponse parsePostmanResponse(PostmanItem requestItem) { List requestList = requestItem.getResponse(); if (CollectionUtils.isEmpty(requestList)) { - return new MsHTTPSamplerProxy(); + return new HttpResponse(); } PostmanResponse requestDesc = requestItem.getResponse().get(0); if (requestDesc == null) { @@ -61,6 +63,9 @@ public abstract class PostmanAbstractParserParser extends ApiImportAbstractPa PostmanUrl url = requestDesc.getOriginalRequest().getUrl(); MsHTTPSamplerProxy request = buildRequest(requestItem.getName(), null, null, requestDesc.getJsonSchema()); request.setRest(parseKeyValue(requestDesc.getOriginalRequest().getUrl().getVariable())); + if (StringUtils.isNotBlank(requestDesc.getBody())) { + request.getBody().setRaw(requestDesc.getBody()); + } if (StringUtils.isNotBlank(request.getPath())) { String path = request.getPath().split("\\?")[0]; path = parseVariable(path); @@ -73,7 +78,10 @@ public abstract class PostmanAbstractParserParser extends ApiImportAbstractPa request.setArguments(parseKeyValue(url == null ? new ArrayList<>() : url.getQuery())); request.setHeaders(parseKeyValue(requestDesc.getHeader())); addBodyHeader(request); - return request; + HttpResponse response = new HttpResponse(); + BeanUtils.copyBean(response, request); + response.setType("HTTP"); + return response; }