Hi everyone,
We like what Jayway has done with REST-assured and going to use it but we have tried many times yet REST-assured always POST application/x-www-form-urlencoded content type instead of the required application/json
Following are what we have tried based on what we managed to find out:
RestAssured.config = new RestAssuredConfig().encoderConfig(EncoderConfig.encoderConfig()
.encodeContentTypeAs("application/json", ContentType.JSON));
given()
.header("Authorization", "Some token")
.contentType(ContentType.JSON)
//.header("Content-Type", "application/json;charset=utf-8")
//.contentType("application/json")
.body("[{\"scan\":\"Something\", \"type\":\"type1\", \"hubId\":1}]")
Response response = post("
http://someServer/2.0/operator/inbounding");
Here are the debug logs snippet:
[debug] - org.apache.http.impl.conn.DefaultClientConnection - Sending request: POST /2.0/operator/inbounding HTTP/1.1
[debug] - org.apache.http.wire - >> "POST /2.0/operator/inbounding HTTP/1.1[\r][\n]"
[debug] - org.apache.http.wire - >> "Content-Type: application/x-www-form-urlencoded; charset=ISO-8859-1[\r][\n]"
[debug] - org.apache.http.wire - >> "Accept: */*[\r][\n]"
[debug] - org.apache.http.wire - >> "Content-Length: 0[\r][\n]"
[debug] - org.apache.http.wire - >> "Connection: Keep-Alive[\r][\n]"
[debug] - org.apache.http.wire - >> "User-Agent: Apache-HttpClient/4.3.5 (java 1.5)[\r][\n]"
[debug] - org.apache.http.wire - >> "Accept-Encoding: gzip,deflate[\r][\n]"
Please help. Thank you very much
Regards,
Clyde