using a Json file in Rest-assured for payload
I use a generic method to read from the json and send that as a string, i.e:
public String generateStringFromResource(String path) throws IOException {
return new String(Files.readAllBytes(Paths.get(path)));
}
So in your example:
@Test
public void post() throws IOException {
String jsonBody = generateStringFromResource("/Users/bmishra/Code_Center/stash/experiments/src/main/resources/Search.json")
given().
contentType("application/json").
body(jsonBody).
when().
post("http://dev/search").
then().
statusCode(200).
body(containsString("true"));
}
After posting the issue with rest-assured team. I have got a fix. I tested the fix and the issue is now resolved.
Message from rest-assured:
It should be fixed now so I've now deployed a new snapshot that should address this issue. Please try version 2.9.1-SNAPSHOT after having added the following Maven repository:
<repositories>
<repository>
<id>sonatype</id>
<url>https://oss.sonatype.org/content/repositories/snapshots/</url>
<snapshots />
</repository>
</repositories>
For more information : https://github.com/jayway/rest-assured/issues/674#issuecomment-210455811