public class BoxJSONRequest extends BoxAPIRequest
This request type extends BoxAPIRequest to provide additional functionality for handling JSON strings. It automatically sets the appropriate "Content-Type" HTTP headers and allows the JSON in the request to be logged.
BoxAPIRequest.RequestHeader| Constructor and Description |
|---|
BoxJSONRequest(BoxAPIConnection api,
URL url,
HttpMethod method)
Constructs an authenticated BoxJSONRequest using a provided BoxAPIConnection.
|
BoxJSONRequest(BoxAPIConnection api,
URL url,
String method)
Constructs an authenticated BoxJSONRequest using a provided BoxAPIConnection.
|
BoxJSONRequest(URL url,
HttpMethod method)
Constructs an authenticated BoxJSONRequest.
|
| Modifier and Type | Method and Description |
|---|---|
protected String |
bodyToString()
Returns a String representation of this request's body used in
BoxAPIRequest.toString(). |
JsonObject |
getBodyAsJsonObject()
Gets the body of this request as a JsonObject.
|
JsonValue |
getBodyAsJsonValue()
Gets the body of this request as a
JsonValue. |
void |
setBody(JsonObject body)
Sets the body of this request to a given JsonObject.
|
void |
setBody(String body)
Sets the body of this request to a given JSON string.
|
addHeader, getBody, getConnectTimeout, getHeaders, getMethod, getReadTimeout, getUrl, isRequestRetryable, isResponseRetryable, resetBody, send, send, sendWithoutRetry, setBody, setBody, setConnectTimeout, setFollowRedirects, setReadTimeout, toString, writeBodypublic BoxJSONRequest(BoxAPIConnection api, URL url, String method)
api - an API connection for authenticating the request.url - the URL of the request.method - the HTTP method of the request.public BoxJSONRequest(BoxAPIConnection api, URL url, HttpMethod method)
api - an API connection for authenticating the request.url - the URL of the request.method - the HTTP method of the request.public BoxJSONRequest(URL url, HttpMethod method)
url - the URL of the request.method - the HTTP method of the request.public void setBody(String body)
setBody in class BoxAPIRequestbody - the JSON string to use as the body.public void setBody(JsonObject body)
body - the JsonObject to use as the body.public JsonObject getBodyAsJsonObject()
public JsonValue getBodyAsJsonValue()
JsonValue.protected String bodyToString()
BoxAPIRequestBoxAPIRequest.toString(). This method returns
null by default.
A subclass may want override this method if the body can be converted to a String for logging or debugging purposes.
bodyToString in class BoxAPIRequest