2016-07-07 3 views
0

Linux 콘솔을 통해 GoogleDrive로 작업하려하지만 본문이 필요한 요청에 문제가 있습니다. 모든 권한이 부여됩니다. 다른 모든 요청 (본문 제외)이 작동하고 있습니다.GoogleDrive API 요청 본문에 무엇을 기록 하시겠습니까?

Google 드라이브에서 폴더를 만들고 싶다면 오류가 발생합니다.

wget --header="Host: www.googleapis.com" --header="Authorization: Bearer MY_TOKEN" --header="Content-Length: 18" --header="Content-Type: application/vnd.google-apps.folder" --method=POST --body-data='{"title":"TemDir"}' 'https://www.googleapis.com/upload/drive/v2/files' -O result.html 

응답은 다음과 같습니다

목록 처음 3 개 파일 : 나는 몸없이 모두 작업 요청을 보낼 때

--2016-07-07 15:03:34-- https://www.googleapis.com/upload/drive/v2/files 
Resolving www.googleapis.com (www.googleapis.com)... 209.85.233.95, 2a00:1450:4010:c08::5f 
Connecting to www.googleapis.com (www.googleapis.com)|209.85.233.95|:443... connected. 
HTTP request sent, awaiting response... 400 Bad Request 
2016-07-07 15:03:35 ERROR 400: Bad Request. 

wget --header="Host: www.googleapis.com" --header="Authorization: Bearer MY_TOKEN" --method=GET 'https://www.googleapis.com/drive/v2/files?orderBy=createdDate&maxResults=3' -O result.html 

비디오 파일을 업로드 :

wget --header='Host: www.googleapis.com' --header='Content-Type: video/mp4' --header='Content-Length: 9356131' --header='Authorization: Bearer MY_TOKEN' --post-file=test.mp4 https://www.googleapis.com/upload/drive/v2/files 
,

는, 내가이 문제를 당신은 올바른 구문을 사용할 필요가

답변

1

를 해결하는 데 도움이 바랍니다./v2에 대한 작업 방법은 다음과 같습니다. 곧/v3으로 이동할 것을 권합니다. 주어진 이름의 폴더가 생성됩니다.

버전/V2를 사용

wget --header="Authorization: Bearer MY_TOKEN" --header="Content-Type: application/json" --method=POST --body-data='{"title":"TemDir121", "mimeType": "application/vnd.google-apps.folder"}' 'https://www.googleapis.com/drive/v2/files' -O result.html 

/V3

wget --header="Authorization: Bearer MY_TOKEN" --header="Content-Type: application/json" --method=POST --body-data='{"name":"TemDir", "mimeType": "application/vnd.google-apps.folder"}' 'https://www.googleapis.com/drive/v3/files' -O result.html 
+0

주셔서 감사합니다. 두 경우 모두 작동합니다. – Alexandr

관련 문제