I have a huge JSON file that will be POST as the payload of the api call to rest for testing purposes. I tried something like:
public void RestTest() throws Exception {
File file = new File("/Users/bmishra/Code_Center/stash/experiments/src/main/resources/Search.json");
String content = null;
given().body(file).with().contentType("application/json").then().expect().
statusCode(200).
body(equalTo("true")).when().post("http://devsearch");
}
and get an error like:
java.lang.UnsupportedOperationException: Internal error: Can't encode /Users/bmishra/Code_Center/stash/experiments/src/main/resources/Search.json to JSON.
I can run by reading the file and passing the body as a string, and this works, but I see that I can directly pass the file object, and this does not work.
After a thorough study, it seems that it does not work. I discovered a problem with self-confidence.
https://github.com/jayway/rest-assured/issues/674
source
share