Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/398.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 如何通过post man post请求传递标头中的对象?_Java_Post_Http Headers_Postman - Fatal编程技术网

Java 如何通过post man post请求传递标头中的对象?

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

我正在使用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(
路径=阵列(
“/腕带/上传”,
“/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)
}