Google 스프레드 시트 apiAPI를 사용하여 python 스크립트를 작성하고 있습니다. 데이터를 읽고 새 파일에 쓰고 지정된 이메일과 파일을 공유하며 새 파일의 ID를 반환합니다.Python으로 Google 스프레드 시트에 사용자를 추가 할 때 Google 드라이브 API에서 500 개의 내부 서버 오류가 발생하는 이유는 무엇입니까?
def read_sheet(self,spreadsheetId):
try:
result=self.service.spreadsheets().get(spreadsheetId=spreadsheetId,includeGridData=True,fields='namedRanges,properties,sheets').execute()
return result
except apiclient.errors.HttpError as e:
traceback.print_exc()
print(e)
sys.exit(1)
def create_spreadsheet(self,data,email):
try:
newid=self.service.spreadsheets().create(body=data,fields='spreadsheetId').execute()
newid=newid.get('spreadsheetId')
self.give_permissions(email,newid)
return newid
except apiclient.errors.HttpError as e:
traceback.print_exc()
print(e)
sys.exit(1)
이 코드는 매우 잘 작동하지만 100 % 정확하지는 않습니다. 때로는 500 내부 서버 오류가 발생하지만 내 계정에 파일이 만들어집니다. 비슷한 스택 오버 플로우 질문 (Getting 500 Error when using Google Drive API to update permissions)을 발견했지만 도움이되지 않았습니다. 나는이 정확한 이유를 알고 싶다. 누구든지 도와 줄 수 있습니까?
EDIT1 :
이 정확한 오류 메시지입니다
https://www.googleapis.com/drive/v3/files/349hsadfhSindfSIins-rasdfisadfOsa3OQmE/permissions?sendNotificationEmail=true & 고도 = JSON & transferOwnership = 거짓 가. "내부 오류 사용자 메시지 :"반환 내부 오류가 은 다음 항목을 공유 방지하는 발생했습니다 템플릿 "">
내부 서버 오류는 홍수 방지입니다. 당신은 빨리하려고합니다. 어떤 종류의 Exponential 백 오프를 구현해야합니다. https://en.wikipedia.org/wiki/Exponential_backoff – DaImTo
어떻게 구현해야합니까[email protected] –
죄송합니다. 저는 파이썬 전문가가 아닙니다. 그것을 위해 인터넷 검색을 시도해보십시오. http://stackoverflow.com/q/27438273/1841839 – DaImTo