[Update Python Google Drive files]

Asked 2 years ago, Updated 2 years ago, 19 views

Hello, I am following the Google Drive restapi manual and proceeding as it is, for some reason If you follow the link, such as the error HttpError 400 when requesting, the method is not allowed It keeps popping up, but I have no idea. The file_id factor value was blocked whether it was wrong or wrong to pass it to the string

def update_file(file_id): # # First retrieve the file from the API. try: file = SERVICE.files().get(fileId=file_id).execute()

    # File's new content.
    media_body = MediaFileUpload(
       'test.tsv', mimetype='text/tsv', resumable=True)
    # # Send the request to the API.
    updated_file = SERVICE.files().update(
        fileId=file_id,
        body=file,
        media_body=media_body,
    ).execute()
    return updated_file
except errors.HttpError as error:
    print('An error occurred: %s' % error)
    return None

python google-drive

2022-09-22 15:00

1 Answers

First of all, http return codes 400 and 405 seem to have occurred, but the two reasons are different.

400 is when the wrong request is made with Bad Request. In this case, you should obtain http header information and analyze it upon request.

405 is Method Not Allowed, which is not supported on the server side.

Usually, http method is put get post delete options head, etc.

If you examine http traffic with a traffic capture tool such as wireshark, or if you are Python, you can get header information from the http module.

I need to check about http.


2022-09-22 15:00

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.