From f60215c6fdec6e1353255091f682b503fae6df6b Mon Sep 17 00:00:00 2001 From: zhangdahai112 Date: Tue, 18 Oct 2022 17:28:59 +0800 Subject: [PATCH] =?UTF-8?q?fix(IDEA=E6=8F=92=E4=BB=B6):=20=E4=BF=AE?= =?UTF-8?q?=E5=A4=8D=E6=96=B0=E7=89=88=E6=9C=AC=E6=8F=92=E4=BB=B6=E5=AF=BC?= =?UTF-8?q?=E5=85=A5=E6=8A=A5=E9=94=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../io/metersphere/api/parse/PostmanAbstractParserParser.java | 3 ++- .../metersphere/service/definition/ApiDefinitionService.java | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/api-test/backend/src/main/java/io/metersphere/api/parse/PostmanAbstractParserParser.java b/api-test/backend/src/main/java/io/metersphere/api/parse/PostmanAbstractParserParser.java index 0db1f87ee0..d74d743eb0 100644 --- a/api-test/backend/src/main/java/io/metersphere/api/parse/PostmanAbstractParserParser.java +++ b/api-test/backend/src/main/java/io/metersphere/api/parse/PostmanAbstractParserParser.java @@ -2,6 +2,7 @@ package io.metersphere.api.parse; import com.fasterxml.jackson.databind.JsonNode; +import com.fasterxml.jackson.databind.node.NullNode; import com.fasterxml.jackson.databind.node.ObjectNode; import io.metersphere.api.dto.definition.request.sampler.MsHTTPSamplerProxy; import io.metersphere.api.dto.definition.response.HttpResponse; @@ -146,7 +147,7 @@ public abstract class PostmanAbstractParserParser extends ApiImportAbstractPa if (StringUtils.equals(bodyMode, PostmanRequestBodyMode.RAW.value())) { parseRawBody(body, postmanBody, bodyMode); } else if (StringUtils.equalsAny(bodyMode, PostmanRequestBodyMode.FORM_DATA.value(), PostmanRequestBodyMode.URLENCODED.value())) { - String s1 = postmanBody.get(bodyMode).toString(); + String s1 = Optional.ofNullable(postmanBody.get(bodyMode)).orElse(NullNode.getInstance()).toString(); String s = parseVariable(s1); List postmanKeyValues = JSON.parseArray(s, PostmanKeyValue.class); body.setKvs(parseKeyValue(postmanKeyValues)); diff --git a/api-test/backend/src/main/java/io/metersphere/service/definition/ApiDefinitionService.java b/api-test/backend/src/main/java/io/metersphere/service/definition/ApiDefinitionService.java index c72cdc0697..7540505282 100644 --- a/api-test/backend/src/main/java/io/metersphere/service/definition/ApiDefinitionService.java +++ b/api-test/backend/src/main/java/io/metersphere/service/definition/ApiDefinitionService.java @@ -1350,7 +1350,7 @@ public class ApiDefinitionService { if (exApiRequest.get("body") != null && apiRequest.get("body") != null) { if (!StringUtils.equals(exApiRequest.get("body").toString(), apiRequest.get("body").toString())) { - if (apiSyncCaseRequest.getBody() && toUpdate) { + if (BooleanUtils.toBoolean(apiSyncCaseRequest.getBody()) && toUpdate) { apiDefinition.setToBeUpdated(true); apiDefinition.setToBeUpdateTime(System.currentTimeMillis()); }