public final class RestMethods extends Object
Modifier and Type | Method and Description |
---|---|
static Object |
jsonDelete(String url)
Wrapper to make JSON DELETE requests.
|
static Object |
jsonDelete(String url,
Map<String,?> params)
Wrapper to make JSON DELETE requests
|
static Object |
jsonGet(String url)
Wrapper to make JSON GET requests
|
static Object |
jsonGet(String url,
Closure c)
Wrapper to make JSON GET requests, the second parameter of the closure parses the data
|
static Object |
jsonGet(String url,
Map<String,?> params)
Wrapper to make JSON GET requests
|
static Object |
jsonGet(String url,
Map<String,?> params,
Closure c)
Wrapper to make JSON GET requests, the second parameter of the closure parses the data
|
static Object |
jsonHead(String url)
Wrapper to make JSON HEAD requests
|
static Object |
jsonHead(String url,
Map<String,?> params)
Wrapper to make JSON HEAD requests
|
static Object |
jsonOptions(String url)
Wrapper to make JSON OPTIONS requests
|
static Object |
jsonOptions(String url,
Map<String,?> params)
Wrapper to make JSON OPTIONS requests
|
static Object |
jsonPatch(String url)
Wrapper to make JSON PATCH requests
|
static Object |
jsonPatch(String url,
Map<String,?> params)
Wrapper to make JSON PATCH requests
|
static Object |
jsonPost(String url)
Wrapper to make JSON POST requests
|
static Object |
jsonPost(String url,
Closure c)
Wrapper to make JSON POST requests, the second parameter of the closure parses the data
|
static Object |
jsonPost(String url,
Map<String,?> params)
Wrapper to make JSON POST requests
|
static Object |
jsonPost(String url,
Map<String,?> params,
Closure c)
Wrapper to make JSON POST requests, the second parameter of the closure parses the data
|
static Object |
jsonPut(String url)
Wrapper to make JSON PUT requests
|
static Object |
jsonPut(String url,
Map<String,?> params)
Wrapper to make JSON PUT requests
|
static Object |
request(String url,
String method,
groovyx.net.http.ContentType contentType,
Closure configClosure)
Simple wrapper that uses the groovy RESTClient
to perform a given http operation with additional options configured in
configClosure . |
static Object |
request(String url,
String method,
groovyx.net.http.ContentType contentType,
Map<String,?> params,
Closure responseClosure)
Simple wrapper that uses the groovy RESTClient
to perform a given http operation.
|
static Object |
xmlDelete(String url)
Wrapper to make XML DELETE requests
Example usage:
|
static Object |
xmlDelete(String url,
Map<String,?> params)
Wrapper to make XML DELETE requests
Example usage:
|
static Object |
xmlGet(String url)
Wrapper to make XML GET requests
Example usage:
|
static Object |
xmlGet(String url,
Closure c)
Wrapper to make XML GET requests, the second parameter of the closure parses the data
Example usage:
|
static Object |
xmlGet(String url,
Map<String,?> params)
Wrapper to make XML GET requests, the second parameter of the closure parses the data
Example usage:
|
static Object |
xmlGet(String url,
Map<String,?> params,
Closure c)
Wrapper to make XML GET requests, the second parameter of the closure parses the data
Example usage:
|
static Object |
xmlHead(String url)
Wrapper to make XML HEAD requests
Example usage:
|
static Object |
xmlHead(String url,
Map<String,?> params)
Wrapper to make XML HEAD requests
Example usage:
|
static Object |
xmlOptions(String url)
Wrapper to make XML OPTIONS requests
Example usage:
|
static Object |
xmlOptions(String url,
Map<String,?> params)
Wrapper to make XML OPTIONS requests
Example usage:
|
static Object |
xmlPatch(String url)
Wrapper to make XML PATCH requests
Example usage:
|
static Object |
xmlPatch(String url,
Map<String,?> params)
Wrapper to make XML PATCH requests
Example usage:
|
static Object |
xmlPost(String url)
Wrapper to make XML POST requests
Example usage:
|
static Object |
xmlPost(String url,
Closure c)
Wrapper to make XML POST requests, the second parameter of the closure parses the data
Example usage:
|
static Object |
xmlPost(String url,
Map<String,?> params)
Wrapper to make XML POST requests
Example usage:
|
static Object |
xmlPost(String url,
Map<String,?> params,
Closure c)
Wrapper to make XML POST requests, the second parameter of the closure parses the data
Example usage:
|
static Object |
xmlPut(String url)
Wrapper to make XML PUT requests
Example usage:
|
static Object |
xmlPut(String url,
Map<String,?> params)
Wrapper to make XML PUT requests
Example usage:
|
public static Object request(String url, String method, groovyx.net.http.ContentType contentType, Map<String,?> params, Closure responseClosure) throws IOException, URISyntaxException
Simple wrapper that uses the groovy RESTClient to perform a given http operation. You can use this method but it's recommended to use one of the other wrapper methods in this class to make life easier.
url
- The URL to connect tomethod
- The type of HTTP methodcontentType
- the content type of the request and responseparams
- A map of parametersresponseClosure
- Groovy Closure to execute after the response has been receivedIOException
URISyntaxException
public static Object request(String url, String method, groovyx.net.http.ContentType contentType, Closure configClosure) throws IOException, URISyntaxException
Simple wrapper that uses the groovy RESTClient
to perform a given http operation with additional options configured in configClosure
. See
RequestConfigDelegate for options.
url
- The URL to connect tomethod
- The type of HTTP methodcontentType
- either a ContentType
or valid content-type string.configClosure
- closure from which to configure options like RequestConfigDelegate.getUri() uri.path,
URIBuilder.setQuery(Map) request parameters, RequestConfigDelegate.setHeaders(Map) headers,
RequestConfigDelegate.setBody(Object) request body and RequestConfigDelegate.getResponse() response handlers.IOException
URISyntaxException
public static Object jsonDelete(String url) throws IOException, URISyntaxException
Wrapper to make JSON DELETE requests.
Example usage:
def responseData = 'http://my.api.com/hello/world/example'.jsonDelete().data
url
- The URL to connect to The URL to connect toIOException
URISyntaxException
public static Object jsonDelete(String url, Map<String,?> params) throws IOException, URISyntaxException
Wrapper to make JSON DELETE requests
Example usage:
def responseData = 'http://my.api.com/hello/world/example'.jsonDelete( [ : ] ).data
url
- The URL to connect to The URL to connect toparams
- A map of parametersIOException
URISyntaxException
public static Object jsonGet(String url, Map<String,?> params, Closure c) throws IOException, URISyntaxException
Wrapper to make JSON GET requests, the second parameter of the closure parses the data
Example usage:
def responseData = 'http://my.api.com/hello/world/example'.jsonGet( [ : ] ) { resp, reader -> return reader }
url
- The URL to connect to The URL to connect toparams
- A map of parametersc
- A closure to call after receiving the responseIOException
URISyntaxException
public static Object jsonGet(String url, Closure c) throws IOException, URISyntaxException
Wrapper to make JSON GET requests, the second parameter of the closure parses the data
Example usage:
def responseData = 'http://my.api.com/hello/world/example'.jsonGet( ) { resp, reader -> return reader }
url
- The URL to connect to The URL to connect toc
- A closure to call after receiving the responseIOException
URISyntaxException
public static Object jsonGet(String url, Map<String,?> params) throws IOException, URISyntaxException
Wrapper to make JSON GET requests
Example usage:
def responseData = 'http://my.api.com/hello/world/example'.jsonGet( [ : ] ).data
url
- The URL to connect to The URL to connect toparams
- A map of parametersIOException
URISyntaxException
public static Object jsonGet(String url) throws IOException, URISyntaxException
Wrapper to make JSON GET requests
Example usage:
def responseData = 'http://my.api.com/hello/world/example'.jsonGet( ).data
url
- The URL to connect to The URL to connect toIOException
URISyntaxException
public static Object jsonHead(String url, Map<String,?> params) throws IOException, URISyntaxException
Wrapper to make JSON HEAD requests
Example usage:
def responseData = 'http://my.api.com/hello/world/example'.jsonHead( [ : ] ).data
url
- The URL to connect to The URL to connect toparams
- A map of parametersIOException
URISyntaxException
public static Object jsonHead(String url) throws IOException, URISyntaxException
Wrapper to make JSON HEAD requests
Example usage:
def responseData = 'http://my.api.com/hello/world/example'.jsonHead( ).data
url
- The URL to connect to The URL to connect toIOException
URISyntaxException
public static Object jsonOptions(String url, Map<String,?> params) throws IOException, URISyntaxException
Wrapper to make JSON OPTIONS requests
Example usage:
def responseData = 'http://my.api.com/hello/world/example'.jsonOptions( [ : ] ).data
url
- The URL to connect to The URL to connect toparams
- A map of parametersIOException
URISyntaxException
public static Object jsonOptions(String url) throws IOException, URISyntaxException
Wrapper to make JSON OPTIONS requests
Example usage:
def responseData = 'http://my.api.com/hello/world/example'.jsonOptions( ).data
url
- The URL to connect to The URL to connect toIOException
URISyntaxException
public static Object jsonPatch(String url, Map<String,?> params) throws IOException, URISyntaxException
Wrapper to make JSON PATCH requests
Example usage:
def responseData = 'http://my.api.com/hello/world/example'.jsonPatch( [ : ] ).data
url
- The URL to connect to The URL to connect toparams
- A map of parametersIOException
URISyntaxException
public static Object jsonPatch(String url) throws IOException, URISyntaxException
Wrapper to make JSON PATCH requests
Example usage:
def responseData = 'http://my.api.com/hello/world/example'.jsonPatch( ).data
url
- The URL to connect to The URL to connect toIOException
URISyntaxException
public static Object jsonPost(String url, Map<String,?> params, Closure c) throws IOException, URISyntaxException
Wrapper to make JSON POST requests, the second parameter of the closure parses the data
Example usage:
def responseData = 'http://my.api.com/hello/world/example'.jsonPost( [ : ] ) { resp, reader -> return reader }
url
- The URL to connect to The URL to connect toparams
- A map of parametersIOException
URISyntaxException
public static Object jsonPost(String url, Closure c) throws IOException, URISyntaxException
Wrapper to make JSON POST requests, the second parameter of the closure parses the data
Example usage:
def responseData = 'http://my.api.com/hello/world/example'.jsonPost( ) { resp, reader -> return reader }
url
- The URL to connect to The URL to connect toIOException
URISyntaxException
public static Object jsonPost(String url, Map<String,?> params) throws IOException, URISyntaxException
Wrapper to make JSON POST requests
Example usage:
def responseData = 'http://my.api.com/hello/world/example'.jsonPost( [ : ] ).data
url
- The URL to connect to The URL to connect toparams
- A map of parametersIOException
URISyntaxException
public static Object jsonPost(String url) throws IOException, URISyntaxException
Wrapper to make JSON POST requests
Example usage:
def responseData = 'http://my.api.com/hello/world/example'.jsonPost( ).data
url
- The URL to connect to The URL to connect toIOException
URISyntaxException
public static Object jsonPut(String url, Map<String,?> params) throws IOException, URISyntaxException
Wrapper to make JSON PUT requests
Example usage:def responseData = 'http://my.api.com/hello/world/example'.jsonPut( [ : ] ).data
url
- The URL to connect to The URL to connect toparams
- A map of parametersIOException
URISyntaxException
public static Object jsonPut(String url) throws IOException, URISyntaxException
Wrapper to make JSON PUT requests
Example usage:
def responseData = 'http://my.api.com/hello/world/example'.jsonPut( ).data
url
- The URL to connect to The URL to connect toIOException
URISyntaxException
public static Object xmlDelete(String url, Map<String,?> params) throws IOException, URISyntaxException
def responseData = 'http://my.api.com/hello/world/example'.xmlDelete( [ : ] ).data
url
- The URL to connect to The URL to connect toparams
- A map of parametersIOException
URISyntaxException
public static Object xmlDelete(String url) throws IOException, URISyntaxException
def responseData = 'http://my.api.com/hello/world/example'.xmlDelete( ).data
url
- The URL to connect to The URL to connect toIOException
URISyntaxException
public static Object xmlGet(String url, Map<String,?> params, Closure c) throws IOException, URISyntaxException
def responseData = 'http://my.api.com/hello/world/example'.xmlGet( [ : ] ) { resp, reader -> return reader }
url
- The URL to connect to The URL to connect toparams
- A map of parametersc
- A closure to call after receiving the responseIOException
URISyntaxException
public static Object xmlGet(String url, Closure c) throws IOException, URISyntaxException
def responseData = 'http://my.api.com/hello/world/example'.xmlGet( ) { resp, reader -> return reader }
url
- The URL to connect to The URL to connect toc
- A closure to call after receiving the responseIOException
URISyntaxException
public static Object xmlGet(String url, Map<String,?> params) throws IOException, URISyntaxException
def responseData = 'http://my.api.com/hello/world/example'.xmlGet( [ : ] ).data
url
- The URL to connect to The URL to connect toparams
- A map of parametersIOException
URISyntaxException
public static Object xmlGet(String url) throws IOException, URISyntaxException
def responseData = 'http://my.api.com/hello/world/example'.xmlGet( ).data
url
- The URL to connect to The URL to connect toIOException
URISyntaxException
public static Object xmlHead(String url, Map<String,?> params) throws IOException, URISyntaxException
def responseData = 'http://my.api.com/hello/world/example'.xmlHead( [ : ] )
url
- The URL to connect toparams
- A map of parametersIOException
URISyntaxException
public static Object xmlHead(String url) throws IOException, URISyntaxException
def responseData = 'http://my.api.com/hello/world/example'.xmlHead( )
url
- The URL to connect toIOException
URISyntaxException
public static Object xmlOptions(String url, Map<String,?> params) throws IOException, URISyntaxException
def responseData = 'http://my.api.com/hello/world/example'.xmlOptions( [ : ] )
url
- The URL to connect toparams
- A map of parametersIOException
URISyntaxException
public static Object xmlOptions(String url) throws IOException, URISyntaxException
def responseData = 'http://my.api.com/hello/world/example'.xmlOptions( )
url
- The URL to connect toIOException
URISyntaxException
public static Object xmlPatch(String url) throws IOException, URISyntaxException
def responseData = 'http://my.api.com/hello/world/example'.xmlPatch( ).data
url
- The URL to connect toIOException
URISyntaxException
public static Object xmlPatch(String url, Map<String,?> params) throws IOException, URISyntaxException
def responseData = 'http://my.api.com/hello/world/example'.xmlPatch( [ : ] ).data
url
- The URL to connect toparams
- A map of parametersIOException
URISyntaxException
public static Object xmlPost(String url, Map<String,?> params, Closure c) throws IOException, URISyntaxException
def responseData = 'http://my.api.com/hello/world/example'.xmlPost( [ : ] ){ resp, reader -> return reader }
url
- The URL to connect toparams
- A map of parametersc
- A closure to call after receiving the responseIOException
URISyntaxException
public static Object xmlPost(String url, Closure c) throws IOException, URISyntaxException
def responseData = 'http://my.api.com/hello/world/example'.xmlPost( ){ resp, reader -> return reader }
url
- The URL to connect toc
- A closure to call after receiving the responseIOException
URISyntaxException
public static Object xmlPost(String url, Map<String,?> params) throws IOException, URISyntaxException
def responseData = 'http://my.api.com/hello/world/example'.xmlPost( [ : ] )
url
- The URL to connect toparams
- A map of parametersIOException
URISyntaxException
public static Object xmlPost(String url) throws IOException, URISyntaxException
def responseData = 'http://my.api.com/hello/world/example'.xmlPost( )
url
- The URL to connect toIOException
URISyntaxException
public static Object xmlPut(String url, Map<String,?> params) throws IOException, URISyntaxException
def responseData = 'http://my.api.com/hello/world/example'.xmlPut( [ : ] )
url
- The URL to connect toparams
- A map of parametersIOException
URISyntaxException
public static Object xmlPut(String url) throws IOException, URISyntaxException
def responseData = 'http://my.api.com/hello/world/example'.xmlPut( )
url
- The URL to connect toIOException
URISyntaxException
Copyright © 2019. All rights reserved.