【问题标题】:How to pass object in the header with post man post request?如何使用邮递员发布请求在标头中传递对象?
【发布时间】:2019-05-21 23:55:11
【问题描述】:

我正在使用邮递员并试图在标头中传递一个对象,但从字符串转换为对象时出错...我该怎么做才能正确?

我正在附上邮递员的图片:

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)

    }

我做错了什么?

谢谢

【问题讨论】:

    标签: java post http-headers postman


    【解决方案1】:

    解决方案:

    我想我找到了解决方案,它将对象从标题移动到正文并将代码更改为:

    @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)
    
    }
    

    【讨论】:

      猜你喜欢
      • 2022-09-23
      • 2018-08-02
      • 2019-04-23
      • 2018-11-07
      • 1970-01-01
      • 2020-02-11
      • 1970-01-01
      • 1970-01-01
      • 2020-07-30
      相关资源
      最近更新 更多