Class DeleteRequest


  • public class DeleteRequest
    extends HttpRequest

    Provides a DELETE Request class for performing simple HTTP request operations. This class provides an easier and safer interface for the Apache HTTP Components library.

    The default connection timeout is 10 seconds and socket read timeout is 60 seconds. Socket connections will also apply any JVM proxy settings automatically.

    By default the maximum response read size is 16 MB. If the response is larger than this an IOException will be thrown. To increase the maximum read limit use the HttpRequest.setReadLimit(int) method.

    In RESTful services the DELETE method is used to delete resources specified by the URI.

    Examples

    The example below performs DELETE request and checks the response status code.

     import com.avoka.tm.http.*
    
     String uri = 'https://service.mycorp.com/secure/rest/accounts/' + customerId
    
     String username = svcDef.paramsMap.username
     String password = svcDef.paramsMap.password
    
     // execute DELETE request and return a HttpResponse object
     HttpResponse response = new DeleteRequest(uri).setBasicAuth(username, password).execute()
    
     // check HttpResponse status code
     if (response.status == 200) {
        // Performed delete
        ...
    
     } else if (response.status == 404) {
        // Not found
        ...
    
     } else {
         throw new RuntimeException(response.statusLine)
     } 
    Since:
    5.0.0
    See Also:
    GetRequest, PatchRequest, PutRequest, PostRequest
    • Constructor Detail

      • DeleteRequest

        public DeleteRequest​(String uri)
        Create a DELETE HTTP request object with the given URI.
        Parameters:
        uri - the request URI (required)