public String post ( String path , String data ) throws Exception { HttpURLConnection connection = null ; try { if ( path . startsWith ( "http" ) ) { connection = init ( path ) ; } else { connection = init ( mBaseUrl + path ) ; } connection . setRequestProperty ( "Content-Type" , "application/json" ) ; connection . setRequestMethod ( METHOD_POST ) ; connection . setDoOutput ( true ) ; writeOutputStream ( connection . getOutputStream ( ) , data ) ; return parseResponse ( connection ) ; } finally { if ( connection != null ) { connection . disconnect ( ) ; } } }
Performs a synchronous post request .