See: Description
Interface | Description |
---|---|
HttpClient |
The main interface to the Http Client service.
|
HttpRequest |
Http Request.
|
HttpResponse |
Http Response.
|
Enum | Description |
---|---|
HttpMethod |
Http Method Type.
|
HttpVersion |
Http Version.
|
// define some basic http request
def httpRequest = httpClient.buildHttpRequest(HttpMethod.GET, 'https://postman-echo.com/get?foo1=bar1&foo2=bar2');
// you can add what you need in the request here:
// httpRequest.putHeader('Content-Type','application/json')
// httpRequest.timeout(6000)
// etc...
// here we define the async processing of the response
Closure processResponse = {result,error ->
if (error != null) {
throw new Exception(error)
}
HttpResponse res = result as HttpResponse
return 'http response code is: ' + res.statusCode()
}
// and here you can send the request with response handling callback
httpRequest.send(processResponse)