File tree 3 files changed +20
-0
lines changed
3 files changed +20
-0
lines changed Original file line number Diff line number Diff line change
1
+ ## 3.9.00 (pending)
2
+ * Issue #362 when passing a string to the body method for a post, route as a string rather than passing to the object mapper.
3
+
4
+
1
5
## 3.8.06
2
6
* issue #359 make the default object mapper lazy so gson can be excluded
3
7
Original file line number Diff line number Diff line change @@ -107,6 +107,9 @@ public RequestBodyEntity body(String body) {
107
107
108
108
@ Override
109
109
public RequestBodyEntity body (Object body ) {
110
+ if (body instanceof String ){
111
+ return body ((String )body );
112
+ }
110
113
return body (getObjectMapper ().writeValue (body ));
111
114
}
112
115
Original file line number Diff line number Diff line change @@ -176,4 +176,17 @@ void theRequestBodyIsAString() {
176
176
Object value = request .getBody ().get ().uniPart ().getValue ();
177
177
assertEquals ("{\" body\" : \" sample\" }" , value );
178
178
}
179
+
180
+ @ Test
181
+ void stringPassedToObjectGetsPassedToString () {
182
+ Object body = "{\" body\" : \" sample\" }" ;
183
+ RequestBodyEntity request = Unirest .post (MockServer .POST )
184
+ .basicAuth ("foo" , "bar" )
185
+ .header ("Content-Type" , "application/json" )
186
+ .queryString ("foo" , "bar" )
187
+ .body (body );
188
+
189
+ Object value = request .getBody ().get ().uniPart ().getValue ();
190
+ assertEquals ("{\" body\" : \" sample\" }" , value );
191
+ }
179
192
}
You can’t perform that action at this time.
0 commit comments