public interface HttpRequest
Modifier and Type | Method and Description |
---|---|
HttpRequest |
appendPath(String path)
Appends the given path to the base URL.
|
<U extends UserDefinedModel> |
setBody(Collection<U> body)
Specifies request body as the serialized form of the provided
UserDefinedModel s. |
HttpRequest |
setBody(CsvData body)
Specifies request body as CSV as returned by
CsvData.asString() . |
HttpRequest |
setBody(JsonArray body)
Specifies request body as JSON as returned by
JsonArray.asString() . |
HttpRequest |
setBody(JsonObject body)
Specifies request body as JSON as returned by
JsonObject.asString() . |
HttpRequest |
setBody(String body)
Specifies request body as a string.
|
<U extends UserDefinedModel> |
setBody(U body)
Specifies request body as the serialized form of the provided
UserDefinedModel . |
HttpRequest |
setBodyParam(String name,
String value)
Specifies a body param.
|
HttpRequest |
setContentType(HttpRequestContentType contentType)
Specifies the
Content-Type header for this HTTP request. |
HttpRequest |
setHeader(String name,
String value)
Specifies an HTTP request header.
|
HttpRequest |
setMethod(HttpMethod method)
Specifies the HTTP method of the request.
|
HttpRequest |
setQuerystringParam(String name,
String value)
Specifies a query string param.
|
HttpRequest |
setResolveTokens(boolean resolveTokens)
Specifies whether to resolve tokens used in headers, body parameters, and body.
|
HttpRequest |
setTimeout(int timeout)
Specifies the maximum time in milliseconds to wait for this HTTP request to complete execution.
|
HttpRequest |
setTokenRequest(TokenRequest tokenRequest)
Specifies the custom tokens that should be resolved in headers, body parameters, and body.
|
HttpRequest setMethod(HttpMethod method)
setBody
method default to
POST
and all other requests default to GET
.method
- HTTP methodHttpRequest setHeader(String name, String value)
setHeader
:
Content-Type
: See the HttpRequestContentType
for supported content types.Authorization
: Pass the current sessionId
on REST API calls.
Learn more about
Session IDs in the Developer Portal.X-VaultAPI-ClientID
: Pass a client ID with this request. Learn more about client IDs in the Developer Portal.name
- header name. Cannot be null or empty.value
- header value. Cannot be null.HttpRequest appendPath(String path)
path
- path to append. Cannot be null.HttpRequest setQuerystringParam(String name, String value)
name
- query string param name. Cannot be null or empty.value
- query string param value. Cannot be null.HttpRequest setBodyParam(String name, String value)
Content-Type: application/x-www-form-urlencoded; charset=utf-8
.
If header is set to Content-Type: text/plain; charset=utf-8
, body param name-value pairs will be
encoded. Otherwise, if body encoding is not expected, use setBody(String)
.name
- body param name. Cannot be null or empty.value
- body param value. Cannot be null.HttpRequest setBody(String body)
Content-Type: application/x-www-form-urlencoded; charset=utf-8
.body
- request body. Cannot be null.HttpRequest setBody(CsvData body)
CsvData.asString()
.
Header defaults to Content-Type: text/csv; charset=utf-8
.body
- request body. Cannot be null.HttpRequest setBody(JsonObject body)
JsonObject.asString()
.
Header defaults to Content-Type: application/json; charset=utf-8
.body
- request body. Cannot be null.HttpRequest setBody(JsonArray body)
JsonArray.asString()
.
Header defaults to Content-Type: application/json; charset=utf-8
.body
- request body. Cannot be null.<U extends UserDefinedModel> HttpRequest setBody(U body)
UserDefinedModel
.
To specify a specific content type to serialize the body to, set the Content-Type header (see setContentType(HttpRequestContentType)
).
Note: This method will fail if the Content-Type header has been set to a value that is not supported by UserDefinedModel
.
Content-Type: application/json; charset=utf-8
.U
- type of UserDefinedModelbody
- request body. Cannot be null.<U extends UserDefinedModel> HttpRequest setBody(Collection<U> body)
UserDefinedModel
s.
To specify a specific content type to serialize the body to, set the Content-Type header (see setContentType(HttpRequestContentType)
).
Note: This method will fail if the Content-Type header has been set to a value that is not supported by UserDefinedModel
.
Content-Type: application/json; charset=utf-8
.U
- type of UserDefinedModelbody
- request body. Cannot be null.HttpRequest setTimeout(int timeout)
timeout
- timeout in millisecondsHttpRequest setTokenRequest(TokenRequest tokenRequest)
For these tokens to be resolved, token resolution must be enabled with setResolveTokens(boolean)
.
tokenRequest
- the token request containing the mapping from token names to their values. Cannot be null.HttpRequest setResolveTokens(boolean resolveTokens)
By default, tokens are not resolved. You must call this method to resolve tokens.
resolveTokens
- true if tokens have to be resolved, otherwise falseHttpRequest setContentType(HttpRequestContentType contentType)
Content-Type
header for this HTTP request.
Calling this method is effectively the same as calling setHeader(String, String)
and passing in "Content-Type" as the
header, for example: setHeader("Content-Type","application/json")
contentType
- the content type to serialize this request's body as. Cannot be null.Copyright © Veeva Systems 2017–2022. All rights reserved.