public void requestDelete ( final String id ) throws SDKException { CloseableHttpResponse response = null ; HttpDelete httpDelete = null ; checkToken ( ) ; try { log . debug ( "pathUrl: " + pathUrl ) ; log . debug ( "id: " + pathUrl + "/" + id ) ; // call the api here log . info ( "Executing delete on: " + this . pathUrl + "/" + id ) ; httpDelete = new HttpDelete ( this . pathUrl + "/" + id ) ; httpDelete . setHeader ( new BasicHeader ( "project-id" , projectId ) ) ; if ( token != null ) { httpDelete . setHeader ( new BasicHeader ( "authorization" , bearerToken . replaceAll ( "\"" , "" ) ) ) ; } response = httpClient . execute ( httpDelete ) ; // check response status RestUtils . checkStatus ( response , HttpURLConnection . HTTP_NO_CONTENT ) ; httpDelete . releaseConnection ( ) ; // return the response of the request } catch ( IOException e ) { // catch request exceptions here log . error ( e . getMessage ( ) , e ) ; if ( httpDelete != null ) { httpDelete . releaseConnection ( ) ; } throw new SDKException ( "Could not http-delete" , e . getStackTrace ( ) , e . getMessage ( ) ) ; } catch ( SDKException e ) { if ( response != null && ( response . getStatusLine ( ) . getStatusCode ( ) == HttpStatus . SC_UNAUTHORIZED ) ) { token = null ; if ( httpDelete != null ) { httpDelete . releaseConnection ( ) ; } requestDelete ( id ) ; return ; } throw new SDKException ( "Could not http-delete or the api response was wrong" , e . getStackTrace ( ) , e . getMessage ( ) ) ; } finally { if ( httpDelete != null ) { httpDelete . releaseConnection ( ) ; } } }
Executes a http delete with to a given id