HellishHeat
HellishHeat

Reputation: 2491

Why this 415 response in a post, mvc test?

Hopefully someone can help. I've been following this [online resource][1], attempting to write an integration test for a RestController:

@Test
public void obfiscated() throws Exception {
    SearchRequest autoCompleteSearchrequest = new SearchRequest();
    autoCompleteSearchrequest.setCity("somewheresville");
    

Upvotes: 1

Views: 417

Answers (2)

HellishHeat
HellishHeat

Reputation: 2491

Despite my, admittedly false, belief that this is taken care of by the @SpringBootTest annotation; I took advice found in another question, and added @EnableWebMvc at class level for my test, and that fixed it.

Upvotes: 2

Marek
Marek

Reputation: 448

try adding consumes = MediaType.APPLICATION_JSON_VALUE to your RequestMapping

Upvotes: 0

Related Questions