JJ Redikes
JJ Redikes

Reputation: 431

How to pass object in the header with post man post request?

I'm using postman and trying to pass an object in the header but getting an error for the converting from string to object... how would I do it right?

I'm attaching pictures from postman:

https://i.sstatic.net/iZp0W.jpg

this is the code on the server:

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

    }

What am I doing wrong?

Thank you

Upvotes: 2

Views: 2124

Answers (1)

JJ Redikes
JJ Redikes

Reputation: 431

Solution:

I think I found solution and it was moving the object from the header to the body and changing the code to be like this:

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

}

Upvotes: 1

Related Questions