8

I have this spring rest controller:

@RestController
@RequestMapping("/communications")
class CommunicationController(private val service: CommunicationService) {

    @ApiOperation(
        produces = APPLICATION_JSON_VALUE, 
        consumes = APPLICATION_JSON_VALUE
    )
    @GetMapping(
        consumes = [APPLICATION_JSON_VALUE], 
        produces = [APPLICATION_JSON_VALUE]
    )
    fun findAll(
        criterias: CommunicationCriterias, 
        page: Pageable
    ): List<CommunicationDTO> = service.findCommunications(criterias, page)

}

When I test this endpoint via the swagger-ui (springfox) interface, i got a 415: content type invalid error. It seems that content-type: application/json is not set in the header.

What is missing ?

Luiggi Mendoza
  • 85,076
  • 16
  • 154
  • 332
louis amoros
  • 2,418
  • 3
  • 19
  • 40
  • Which version of swagger you use? – sven.kwiotek Nov 27 '18 at 10:11
  • I used `io.springfox:springfox-swagger2:2.9.2` and `io.springfox:springfox-swagger-ui:2.9.2` but I finally removed de springfox dependencies and went with the classic swagger editor... – louis amoros Nov 27 '18 at 16:36
  • I have same issue at springfox-swagger2+springfox-swagger-ui v 2.9.2 – Capacytron Oct 15 '19 at 12:11
  • Understand that this is an old post but somebody just posted an answer that worked for me, so posting here for reference : https://stackoverflow.com/questions/62078786/springfox-swagger-ui-not-sending-with-content-type-header – ipohfly May 29 '20 at 18:12

1 Answers1

1

There is nothing to consume in HTTP GET request. I think you should remove the consumes from @GetMapping and @ApiOperation.

Tuomo Kestilä
  • 401
  • 5
  • 4
  • That makes sense since there is no json request payload. Thanks man. Had not thought of that – Given Aug 04 '20 at 10:38