Trying to GET a Google Spreadsheet in Java is returning HTTP error 405
Been working on this all day and have gotten no where with it.

My Java code looks like this:

    final URL url = new URL(String.format("https://spreadsheets.google.com/feeds/download/spreadsheets/Export?key=%s&exportFormat=tsv&gid=0", spreadsheetId));
    HttpURLConnection conn = (HttpURLConnection) url.openConnection();    
    conn.setRequestProperty("Authorization",   "GoogleLogin auth=" + wiseAuth.getAuthToken());    
    conn.setRequestProperty("GData-Version", "3.0");
    
    conn.setRequestMethod("GET");
        
    conn.setDoOutput(true); // trouble here, see below
    
    conn.setInstanceFollowRedirects(true);    
    conn.connect();

I always get a FileNotFound error when attempting to do `conn.getInputStream()`. I narrowed it down to being that the response code is 405 Method Not Allowed. The exception is returning me my URL and I can access the page just fine in my browser.

It was then that I discovered that `setDoOutput(true)` executes a POST internally. But if I remove that line, `conn.getInputStream()` is null, and `conn.getOutputStream()` appears to return nothing--though maybe I am setting it up wrong?
Trying to GET a Google Spreadsheet in Java is returning HTTP error 405
===

Been working on this all day and have gotten no where with it.

My Java code looks like this:

    final URL url = new URL(String.format("https://spreadsheets.google.com/feeds/download/spreadsheets/Export?key=%s&exportFormat=tsv&gid=0", spreadsheetId));
    HttpURLConnection conn = (HttpURLConnection) url.openConnection();    
    conn.setRequestProperty("Authorization",   "GoogleLogin auth=" + wiseAuth.getAuthToken());    
    conn.setRequestProperty("GData-Version", "3.0");
    
    conn.setRequestMethod("GET");
        
    conn.setDoOutput(true); // trouble here, see below
    
    conn.setInstanceFollowRedirects(true);    
    conn.connect();

I always get a FileNotFound error when attempting to do `conn.getInputStream()`. I narrowed it down to being that the response code is 405 Method Not Allowed. The exception is returning me my URL and I can access the page just fine in my browser.

It was then that I discovered that `setDoOutput(true)` executes a POST internally. But if I remove that line, `conn.getInputStream()` is null, and `conn.getOutputStream()` appears to return nothing--though maybe I am setting it up wrong?