我正在使用 postman 并尝试在 header 中传递一个对象,但在从字符串转换为对象时出现错误...我该怎么做?
我附上 postman 的照片:
这是服务器上的代码:
@RequestMapping(
path= arrayOf(
"/wristbands/upload",
"/wristbands/upload/"),
method = arrayOf(RequestMethod.POST),
consumes = arrayOf(MediaType.APPLICATION_JSON_UTF8_VALUE))
open fun wristbandProcessNewAlgorithem(@RequestHeader(name = "X-V", required = true) wristbandRecords: WristbandRecordNewInputDTO): ResponseEntity<*>{
var res=wristbandProcessingService.processWristbandNewAlgorithem(wristbandRecords)
return ResponseEntity(res,HttpStatus.OK)
}
我做错了什么?
谢谢
最佳答案
解决方案:
我想我找到了解决方案,它将对象从标题移动到正文并将代码更改为如下所示:
@RequestMapping(
path= arrayOf(
"/wristbands/upload",
"/wristbands/upload/"),
method = arrayOf(RequestMethod.POST),
headers = arrayOf("X-V"),
consumes = arrayOf(MediaType.APPLICATION_JSON_UTF8_VALUE))
open fun wristbandProcessNewAlgorithem(@RequestBody wristbandRecords: WristbandRecordNewInputDTO): ResponseEntity<*>{
var res=wristbandProcessingService.processWristbandNewAlgorithem(wristbandRecords)
return ResponseEntity(res,HttpStatus.OK)
}
关于java - 如何通过 post man post 请求在 header 中传递对象?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53885981/