Core of the DSL for building REST requests
| Type | Name and description |
|---|---|
java.lang.Class |
acceptType |
java.lang.Object |
body |
org.springframework.http.HttpHeaders |
headers |
org.springframework.util.MultiValueMap<java.lang.String, java.lang.Object> |
mvm |
java.util.Map<java.lang.String, java.lang.Object> |
urlVariables |
| Type | Name and description |
|---|---|
RequestCustomizer |
accept(java.lang.String... contentTypes)Sets the Accept HTTP header to the given value. |
RequestCustomizer |
accept(java.lang.Class responseType, java.lang.String... contentTypes)Sets the Accept HTTP header to the given value. |
RequestCustomizer |
auth(java.lang.String username, java.lang.String password)Used to configure BASIC authentication. |
RequestCustomizer |
auth(java.lang.String accessToken)Sets the Authorization HTTP header to the given value. |
RequestCustomizer |
body(java.lang.Object content)Sets the body of the request to the given argument. |
RequestCustomizer |
contentType(java.lang.String contentType)Sets the Content-Type HTTP header to the given value. |
org.springframework.http.HttpEntity |
createEntity() |
RequestCustomizer |
header(java.lang.String name, java.lang.String value)Sets an HTTP header to the given name and value. |
RequestCustomizer |
json(groovy.lang.Closure callable)Sets the body of the request to the JSON defined by the closure. |
RequestCustomizer |
json(grails.converters.JSON json)Sets the body of the request to the passed JSON |
RequestCustomizer |
json(org.grails.web.json.JSONElement json)Sets the body of the request to the passed JSON |
RequestCustomizer |
json(java.lang.String json)Sets the body of the request to the passed JSON string |
RequestCustomizer |
json(java.lang.Object object)Converts the given object to JSON and sets the body to the converted JSON object |
void |
setProperty(java.lang.String name, java.lang.Object value)Sets multipart values within the request body |
RequestCustomizer |
urlVariables(java.util.Map<java.lang.String, java.lang.Object> variables)Configures any variables used in the case of a templated URL. |
RequestCustomizer |
xml(groovy.lang.Closure closure)Sets the body of the request to the XML defined by the closure. |
RequestCustomizer |
xml(grails.converters.XML xml)Sets the body of the request to the XML converter argument. |
RequestCustomizer |
xml(java.lang.String xml)Sets the body of the request to the XML string argument. |
RequestCustomizer |
xml(groovy.util.slurpersupport.GPathResult xml)Sets the body of the request to the XML GPathResult argument. |
RequestCustomizer |
xml(java.lang.Object object)Converts the given object to XML using Grails' converters and sets the XML as the body of the request |
| Methods inherited from class | Name |
|---|---|
class java.lang.Object |
java.lang.Object#wait(long, int), java.lang.Object#wait(long), java.lang.Object#wait(), java.lang.Object#equals(java.lang.Object), java.lang.Object#toString(), java.lang.Object#hashCode(), java.lang.Object#getClass(), java.lang.Object#notify(), java.lang.Object#notifyAll() |
Sets the Accept HTTP header to the given value. Example:
restBuilder.get("http://..") {
accept "application/xml"
}
contentTypes - The content typesSets the Accept HTTP header to the given value. Example:
restBuilder.get("http://..") {
accept XML
}
responseType - The expected response typecontentTypes - The content typesUsed to configure BASIC authentication. Example:
builder.put("http://..") {
auth "myuser", "mypassword"
}
username - The usernamepassword - The passwordSets the Authorization HTTP header to the given value. Used typically to pass OAuth access tokens.
builder.put("http://..") {
auth myToken
}
accessToken - The access tokenSets the body of the request to the given argument. Note that if you argument is not convertable to a message body an exception will be thrown. You can register new converters using restBuilder.restTemplate.getMessageConverters().add(..)
content - The body contentSets the Content-Type HTTP header to the given value. Example:
restBuilder.put("http://..") {
contentType "application/xml"
}
contentType - The content typeSets an HTTP header to the given name and value. Example:
restBuilder.get("http://..") {
header "Accept", "text/xml"
}
name - The name of the headervalue - The value of the headerSets the body of the request to the JSON defined by the closure. The closure uses JSONBuilder to product a JSON object. Example:
restBuilder.put("http://..") {
json {
name = "test-group"
description = "A temporary test group"
}
}
callable - The callable closureSets the body of the request to the passed JSON
json - The JSON objectSets the body of the request to the passed JSON
json - The JSON objectSets the body of the request to the passed JSON string
json - The JSON objectConverts the given object to JSON and sets the body to the converted JSON object
object - The object to convert to JSONSets multipart values within the request body
name - The name of the multipartvalue - The value of the multipartConfigures any variables used in the case of a templated URL. Example:
restBuilder.get("http://../book/{id}") {
urlVariables id:1
}
variables - The URL variablesSets the body of the request to the XML defined by the closure. Uses groovy.xml.StreamingMarkupBuilder to produce the XML
closure - The closure that defines the XMLSets the body of the request to the XML converter argument.
xml - The XML to be used as the body of the requestSets the body of the request to the XML string argument.
xml - The XML to be used as the body of the requestSets the body of the request to the XML GPathResult argument.
xml - The XML to be used as the body of the requestConverts the given object to XML using Grails' converters and sets the XML as the body of the request
object - The object