InputStream getContent ( String url ) throws IOException , NsApiException { Request request = new Request . Builder ( ) . url ( url ) . get ( ) . build ( ) ; try { Response response = client . newCall ( request ) . execute ( ) ; if ( response . body ( ) == null ) { log . error ( "Error while calling the webservice, entity is null" ) ; throw new NsApiException ( "Error while calling the webservice, entity is null" ) ; } return response . body ( ) . byteStream ( ) ; } catch ( RuntimeException e ) { log . error ( "Error while calling the webservice, entity is null" ) ; throw new NsApiException ( "Error while calling the webservice, entity is null" , e ) ; } }
Handling the webservice call