diff --git a/modules/spring-mock-mvc/src/main/java/io/restassured/module/mockmvc/internal/MockMvcRequestSpecificationImpl.java b/modules/spring-mock-mvc/src/main/java/io/restassured/module/mockmvc/internal/MockMvcRequestSpecificationImpl.java index 8afd57af5..7814374b5 100644 --- a/modules/spring-mock-mvc/src/main/java/io/restassured/module/mockmvc/internal/MockMvcRequestSpecificationImpl.java +++ b/modules/spring-mock-mvc/src/main/java/io/restassured/module/mockmvc/internal/MockMvcRequestSpecificationImpl.java @@ -191,6 +191,11 @@ public MockMvcRequestSpecification contentType(ContentType contentType) { return header(CONTENT_TYPE, contentType.toString()); } + public MockMvcRequestSpecification contentType(MediaType mediaType) { + notNull(mediaType, "mediaType"); + return header(CONTENT_TYPE, mediaType.toString()); + } + public MockMvcRequestSpecification contentType(String contentType) { notNull(contentType, "contentType"); return header(CONTENT_TYPE, contentType); diff --git a/modules/spring-mock-mvc/src/main/java/io/restassured/module/mockmvc/specification/MockMvcRequestSpecification.java b/modules/spring-mock-mvc/src/main/java/io/restassured/module/mockmvc/specification/MockMvcRequestSpecification.java index b226714c8..9460900f5 100644 --- a/modules/spring-mock-mvc/src/main/java/io/restassured/module/mockmvc/specification/MockMvcRequestSpecification.java +++ b/modules/spring-mock-mvc/src/main/java/io/restassured/module/mockmvc/specification/MockMvcRequestSpecification.java @@ -57,6 +57,16 @@ public interface MockMvcRequestSpecification extends MockMvcRequestSender { */ MockMvcRequestSpecification contentType(ContentType contentType); + /** + * Specify the content type of the request. + * + * @param mediaType The content type of the request + * @return The request specification + * @see ContentType + * @see MediaType + */ + MockMvcRequestSpecification contentType(MediaType mediaType); + /** * Specify the content type of the request. * diff --git a/modules/spring-web-test-client/src/main/java/io/restassured/module/webtestclient/internal/WebTestClientRequestSpecificationImpl.java b/modules/spring-web-test-client/src/main/java/io/restassured/module/webtestclient/internal/WebTestClientRequestSpecificationImpl.java index 78802875c..89f562c2b 100644 --- a/modules/spring-web-test-client/src/main/java/io/restassured/module/webtestclient/internal/WebTestClientRequestSpecificationImpl.java +++ b/modules/spring-web-test-client/src/main/java/io/restassured/module/webtestclient/internal/WebTestClientRequestSpecificationImpl.java @@ -118,6 +118,12 @@ public WebTestClientRequestSpecification contentType(ContentType contentType) { return header(CONTENT_TYPE, contentType.toString()); } + @Override + public WebTestClientRequestSpecification contentType(MediaType mediaType) { + notNull(mediaType, "mediaType"); + return header(CONTENT_TYPE, mediaType.toString()); + } + @Override public WebTestClientRequestSpecification contentType(String contentType) { notNull(contentType, "contentType"); diff --git a/modules/spring-web-test-client/src/main/java/io/restassured/module/webtestclient/specification/WebTestClientRequestSpecification.java b/modules/spring-web-test-client/src/main/java/io/restassured/module/webtestclient/specification/WebTestClientRequestSpecification.java index 7ec09c1c1..b4aaa92e9 100644 --- a/modules/spring-web-test-client/src/main/java/io/restassured/module/webtestclient/specification/WebTestClientRequestSpecification.java +++ b/modules/spring-web-test-client/src/main/java/io/restassured/module/webtestclient/specification/WebTestClientRequestSpecification.java @@ -46,6 +46,16 @@ public interface WebTestClientRequestSpecification extends WebTestClientRequestS */ WebTestClientRequestSpecification contentType(ContentType contentType); + /** + * Specify the content type of the request. + * + * @param mediaType The content type of the request + * @return The request specification + * + * @see ContentType + */ + WebTestClientRequestSpecification contentType(MediaType mediaType); + /** * Specify the content type of the request. *