The Google Docs API returns 503 Service Unavailable when downloading a file. Something has changed?

I have applications that use the Google Docs API. Until recently, downloading using HTTP endpoints worked fine. Recently, an unexpected error occurred while downloading. The first call to create a session (which returns a revolving URL) works fine and returns a revolving URL. The attempt then to send the contents of the file to a revolving URL is 503.

The corresponding piece of code causing the error is this:

URL url = new URL(resumableFileUploadUrl); conn = (HttpURLConnection) url.openConnection(); conn.addRequestProperty("client_id", OAuth2Client.CLIENT_ID); conn.addRequestProperty("client_secret", OAuth2Client.CLIENT_SECRET); conn.setRequestProperty("Authorization", "OAuth " + GetAuthToken()); conn.setRequestProperty("X-Upload-Content-Length", String.valueOf(fileContents.length())); //back to 0 conn.setRequestProperty("X-Upload-Content-Type", "text/xml"); conn.setRequestProperty("Content-Type", "text/xml"); conn.setRequestProperty("Content-Length", String.valueOf(fileContents.length())); conn.setRequestProperty("Slug", fileName); if(isUpdate) { conn.setRequestProperty("If-Match", "*"); conn.setRequestMethod("PUT"); } else { conn.setRequestMethod("POST"); } conn.setRequestProperty("GData-Version", "3.0"); conn.setRequestProperty("User-Agent", "GPSLogger for Android"); conn.setUseCaches(false); conn.setDoInput(true); conn.setDoOutput(true); DataOutputStream wr = new DataOutputStream( conn.getOutputStream()); wr.writeBytes(fileContents); wr.flush(); wr.close(); int code = conn.getResponseCode(); newLocation = conn.getHeaderField("location"); 

The above code is used both to create a session to obtain a renewable URL, and to host the contents of a file for a renewable URL.

What is part of this Android action. I am including a link to the original activity, as it would be fairly easy to reproduce the problem by simply cloning the repository. The code remained untouched for a year.

Recently, something has changed that could cause this?

I would like to avoid using the Google Drive APIs for now, as I have not changed the code, and the same code is used in several of my other applications in this area.

+6
source share
2 answers

One of the most annoying "features" is the undocumented speed limit when requesting images, each request of which must be authenticated. Speeding is about 10 / s.

0
source

Perhaps you are using the Google API v2, which is deprecated at the moment. Read the following message:

 https://developers.google.com/google-apps/documents-list/terms 
0
source

Source: https://habr.com/ru/post/946542/


All Articles