Java 如何通过post man post请求传递标头中的对象?
我正在使用postman并尝试在标头中传递一个对象,但在从字符串转换为对象时出错。。。我该怎么做才对呢 我附上邮递员的照片: 这是服务器上的代码:Java 如何通过post man post请求传递标头中的对象?,java,post,http-headers,postman,Java,Post,Http Headers,Postman,我正在使用postman并尝试在标头中传递一个对象,但在从字符串转换为对象时出错。。。我该怎么做才对呢 我附上邮递员的照片: 这是服务器上的代码: @RequestMapping( path= arrayOf( "/wristbands/upload", "/wristbands/upload/"), method = arrayOf(RequestMethod.POST), consumes = ar
@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(
路径=阵列(
“/腕带/上传”,
“/wristbands/upload/”,
method=arrayOf(RequestMethod.POST),
consumes=arrayOf(MediaType.APPLICATION\u JSON\u UTF8\u值))
打开有趣的腕带进程newalgorithem(@RequestHeader(name=“X-V”,required=true)腕带记录:腕带记录newinputdto):ResponseEntity{
var res=腕带处理服务。处理腕带新算法(腕带记录)
返回响应性(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)
}
@RequestMapping(
路径=阵列(
“/腕带/上传”,
“/wristbands/upload/”,
method=arrayOf(RequestMethod.POST),
标题=排列(“X-V”),
consumes=arrayOf(MediaType.APPLICATION\u JSON\u UTF8\u值))
打开趣味腕带处理新算法(@RequestBody腕带记录:腕带记录新输入到):ResponseEntity{
var res=腕带处理服务。处理腕带新算法(腕带记录)
返回响应性(res,HttpStatus.OK)
}