Package com.veeva.vault.sdk.api.http
Interface HttpRequest
public interface HttpRequest
Represents an HTTP request.
-
Method Summary
Modifier and TypeMethodDescriptionappendPath
(String path) Appends the given path to the base URL.Specifies request body as CSV as returned byCsvData.asString()
.Specifies request body as JSON as returned byJsonArray.asString()
.setBody
(JsonObject body) Specifies request body as JSON as returned byJsonObject.asString()
.Specifies request body as a string.<U extends UserDefinedModel>
HttpRequestsetBody
(Collection<U> body) Specifies request body as the serialized form of the providedUserDefinedModel
s.<U extends UserDefinedModel>
HttpRequestsetBody
(U body) Specifies request body as the serialized form of the providedUserDefinedModel
.setBodyParam
(String name, String value) Specifies a body param.setContentType
(HttpRequestContentType contentType) Specifies theContent-Type
header for this HTTP request.setContentType
(com.veeva.vault.sdk.infrastructure.http.HttpRequestContentEnumType contentType) Specifies theContent-Type
header for this HTTP request.Specifies an HTTP request header.setMethod
(HttpMethod method) Specifies the HTTP method of the request.setQuerystringParam
(String name, String value) Specifies a query string param.setResolveTokens
(boolean resolveTokens) Specifies whether to resolve tokens used in headers, body parameters, and body.setTimeout
(int timeout) Specifies the maximum time in milliseconds to wait for this HTTP request to complete execution.setTokenRequest
(TokenRequest tokenRequest) Specifies the custom tokens that should be resolved in headers, body parameters, and body.
-
Method Details
-
setMethod
Specifies the HTTP method of the request. If not specified, requests with asetBody
method default toPOST
and all other requests default toGET
.- Parameters:
method
- HTTP method- Returns:
- this HTTP request
-
setHeader
Specifies an HTTP request header. Each call with the same name adds to the List of already specified values. Use only the following request headers withsetHeader
:Content-Type
: See theHttpRequestContentType
for supported content types.Authorization
: Pass the currentsessionId
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.
- Parameters:
name
- header name. Cannot be null or empty.value
- header value. Cannot be null.- Returns:
- this HTTP request
-
appendPath
Appends the given path to the base URL.- Parameters:
path
- path to append. Cannot be null.- Returns:
- this HTTP request
-
setQuerystringParam
Specifies a query string param.- Parameters:
name
- query string param name. Cannot be null or empty.value
- query string param value. Cannot be null.- Returns:
- this HTTP request
-
setBodyParam
Specifies a body param. Header defaults toContent-Type: application/x-www-form-urlencoded; charset=utf-8
. If header is set toContent-Type: text/plain; charset=utf-8
, body param name-value pairs will be encoded. Otherwise, if body encoding is not expected, usesetBody(String)
.- Parameters:
name
- body param name. Cannot be null or empty.value
- body param value. Cannot be null.- Returns:
- this HTTP request
-
setBody
Specifies request body as a string. Header defaults toContent-Type: application/x-www-form-urlencoded; charset=utf-8
.- Parameters:
body
- request body. Cannot be null.- Returns:
- this HTTP request
-
setBody
Specifies request body as CSV as returned byCsvData.asString()
. Header defaults toContent-Type: text/csv; charset=utf-8
.- Parameters:
body
- request body. Cannot be null.- Returns:
- this HTTP request
-
setBody
Specifies request body as JSON as returned byJsonObject.asString()
. Header defaults toContent-Type: application/json; charset=utf-8
.- Parameters:
body
- request body. Cannot be null.- Returns:
- this HTTP request
-
setBody
Specifies request body as JSON as returned byJsonArray.asString()
. Header defaults toContent-Type: application/json; charset=utf-8
.- Parameters:
body
- request body. Cannot be null.- Returns:
- this HTTP request
-
setBody
Specifies request body as the serialized form of the providedUserDefinedModel
. To specify a specific content type to serialize the body to, set the Content-Type header (seesetContentType(HttpRequestContentType)
).Note: This method will fail if the Content-Type header has been set to a value that is not supported by
Header defaults toUserDefinedModel
.Content-Type: application/json; charset=utf-8
.- Type Parameters:
U
- type of UserDefinedModel- Parameters:
body
- request body. Cannot be null.- Returns:
- this HTTP request
-
setBody
Specifies request body as the serialized form of the providedUserDefinedModel
s. To specify a specific content type to serialize the body to, set the Content-Type header (seesetContentType(HttpRequestContentType)
).Note: This method will fail if the Content-Type header has been set to a value that is not supported by
Header defaults toUserDefinedModel
.Content-Type: application/json; charset=utf-8
.- Type Parameters:
U
- type of UserDefinedModel- Parameters:
body
- request body. Cannot be null.- Returns:
- this HTTP request
-
setTimeout
Specifies the maximum time in milliseconds to wait for this HTTP request to complete execution. Must be greater than 0.- Parameters:
timeout
- timeout in milliseconds- Returns:
- this HTTP request
-
setTokenRequest
Specifies the custom tokens that should be resolved in headers, body parameters, and body.For these tokens to be resolved, token resolution must be enabled with
setResolveTokens(boolean)
.- Parameters:
tokenRequest
- the token request containing the mapping from token names to their values. Cannot be null.- Returns:
- this HTTP request
-
setResolveTokens
Specifies whether to resolve tokens used in headers, body parameters, and body. Tokens used in query string parameters are not resolved.By default, tokens are not resolved. You must call this method to resolve tokens.
- Parameters:
resolveTokens
- true if tokens have to be resolved, otherwise false- Returns:
- this HTTP request
-
setContentType
HttpRequest setContentType(com.veeva.vault.sdk.infrastructure.http.HttpRequestContentEnumType contentType) Specifies theContent-Type
header for this HTTP request. Calling this method is effectively the same as callingsetHeader(String, String)
and passing in "Content-Type" as the header, for example:setHeader("Content-Type","application/json")
- Parameters:
contentType
- the content type to serialize this request's body as. Cannot be null.- Returns:
- this HTTP request
-
setContentType
Specifies theContent-Type
header for this HTTP request. Calling this method is effectively the same as callingsetHeader(String, String)
and passing in "Content-Type" as the header, for example:setHeader("Content-Type","application/json")
- Parameters:
contentType
- the content type to serialize this request's body as. Cannot be null.- Returns:
- this HTTP request
-