网站建设定制开发postman怎么传对象list_postman 传递json的参数里面带了List对象

网站建设定制开发最近开发一款软件,网站建设定制开发遇到个问题,需要创建个方法接受post的请求。

后台写好了:

/**

* 将OSS报警导入钉钉机器人

* @param checksum

* @param content

* @return*/@RequestMapping(value= "/receive", method = {RequestMethod.POST}, produces = "application/json;charset=UTF-8")

@ResponseBodypublic ResultDatareceiveWarning(@RequestParam String checksum, @RequestParam String content) {try{

log.info("receiveWarning 入参,content:{},checksum:{}", content,checksum);

OssWarning ossWarning= JSON.parseObject(content, OssWarning.class);if(ossWarning==null ||ossWarning.getBucket()==null|| ossWarning.getAuditResult()==null){returnResultData.error(PmsErrorEnum.PARAM_VALID_ERROR);

}

String bucket=ossWarning.getBucket();

AuditResult auditResult=ossWarning.getAuditResult();if(!MAIZUO_BUCKET.equals(bucket)){returnResultData.error(PmsErrorEnum.PARAM_VALID_ERROR);

}if(AUDIT_SUCC.equals(auditResult.getResoureStatus())){returnResultData.error(PmsErrorEnum.PARAM_VALID_ERROR);

}

log.info("receiveWarning 过滤之后的入参,ossWarning:{}", JSON.toJSONString(content));

sendWarningUtil.sendCallBackError(ossWarning,content);return ResultData.success(true);

}catch(MzException me) {

log.warn("SendWarningController.receiveWarning-->OSS处理图片发生业务异常,content:{},me:{}", content, me);returnResultData.error(me);

}catch(Exception e) {

log.warn("SendWarningController.receiveWarning-->字符串格式异常,content:{},e:{}", content, e);returnResultData.error(SystemErrorEnum.SYSTEM_ERROR);

}

}

问题很简单:post请求的参数 @Request String checksum 和@Request String content,

然后自己在里面模拟了post请求:

下面是我模拟的请求:

后来发现个问题:只要第二个参数:里面有list,模拟请求就会失败;

这是可以运行的参数:主要是第二个参数content,第一个checksum没问题

可以运行的:

{"bucket":"maizuo-saas","freezed":false,"object":"xxx.jpg","region":"cn-hangzhou","stock":false}

不可以运行的:

{"results":[{"label":"porn","rate":100,"scene":"porn","suggestion":"block"},{"label":"normal","rate":99.6,"scene":"terrorism","suggestion":"pass"}]}

我试了一下 只要参数里面带有list ,postman就没有任何返回,也不提示报错信息,只要去掉list,就恢复正常。

如下可以运行的postMan:

加上list之后不能运行的postman:

由于没有任何报错信息,没法修改程序,

后来想到了使用curl进行模拟,看看能不能有返回信息:

这是curl:

curl https://pms-pre.maitix.com/pms/warning/receive -X POST -d '{"checksum": "kanzeoss","content":"{"bucket":"maizuo-saas","freezed":false,"object":"xxx.jpg","region":"cn-hangzhou","ScanResult":{"code":200,"dataId":"5C919E2FBD6CD6940D4A8B46","msg":"OK","results":[{"label":"porn","rate":100,"scene":"porn","suggestion":"block"},{"label":"normal","rate":99.6,"scene":"terrorism","suggestion":"pass"}],"taskId":"img1ZxzVQUuAz36scZEjyGXzx-1qpzhY"},"auditResult":{"resoureStatus":1,"suggestion":"failed"},"stock":false}"}' --header "Content-Type: application/json"

结果立即出来了:

{"timestamp":1605600704113,"status":400,"error":"Bad Request","exception":"org.springframework.web.bind.MissingServletRequestParameterException","message":"Required String parameter 'checksum' is not present","path":"/pms/warning/receive"}

报错信息里面有:

原因是:我们使用postMan的时候,选择有误:应该使

(1)使用Body;

(2)使用form-data;就可以了

写的程序没有任何问题;只是postMan模拟方式不对而已

相关资源:
网站建设定制开发 软件系统开发定制 定制软件开发 软件开发定制 定制app开发 app开发定制 app开发定制公司 电商商城定制开发 定制小程序开发 定制开发小程序 客户管理系统开发定制 定制网站 定制开发 crm开发定制 开发公司 小程序开发定制 定制软件 收款定制开发 企业网站定制开发 定制化开发 android系统定制开发 定制小程序开发费用 定制设计 专注app软件定制开发 软件开发定制定制 知名网站建设定制 软件定制开发供应商 应用系统定制开发 软件系统定制开发 企业管理系统定制开发 系统定制开发