gpt4 book ai didi

java - 如何通过 post man post 请求在 header 中传递对象?

转载 作者:行者123 更新时间:2023-11-30 05:51:14 25 4
gpt4 key购买 nike

我正在使用 postman 并尝试在 header 中传递一个对象,但在从字符串转换为对象时出现错误...我该怎么做?

我附上 postman 的照片:

https://imgur.com/a/5wAxIYf

这是服务器上的代码:

@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/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com