2017-01-09 10 views
0

私はいくつかのドライブ機能を実装するアプリケーションを構築しています。今、私はgoogle-api-ruby-client gemを使ってファイルを共有しようとしています。私は次のコードを使用していくつかの問題を抱えています。私はこのエラーを解決することができないRails Drive Rest Api | google api client gemを使ってファイルを共有する

{ 
"error": { 
"errors": [ 
    { 
    "domain": "global", 
    "reason": "required", 
    "message": "The permission type field is required.", 
    "locationType": "other", 
    "location": "permission.type" 
    } 
    ], 
    "code": 400, 
    "message": "The permission type field is required." 
} 

}

:私はこのコード、コールバック・ショーこれを実行

#Here, I create a DriveService object and I authorize it. 
#This works fine. In my app I list drive files well. 
@drive = Google::Apis::DriveV3::DriveService.new 
@drive.authorization = @token[:access_token] 

#Here, first I create a permission object with some parameters 
#Then I call create_permission to share the file to a other user 
per=Google::Apis::DriveV3::Permission.new(type: "user", role: "writer",email_address: "[email protected]") 
@drive.create_permission(file_id:"0B8XBWuVEmvN8YS01OXNUcHhOYWs",permission_object: per, fields: "id", &callback) 

。誰か助けてくれますか?

+0

デバッガが@ drive.create_permission行を指しています –

答えて

0

デバッガは@ drive.create_permission行を指しているので、その行の 'type'権限を探していることを意味します。ドキュメントは、これがないと言うように、私は許可オブジェクトを渡す場合、私は、なぜ知らない

@drive.create_permission(file_id:"0B8XBWuVEmvN8YS01OXNUcHhOYWs",type: "user", role: "writer", permission_object: per, fields: "id", &callback) 
+0

動作しません、私はそのエラーがオブジェクト "per"と関連していると思います。 http://www.rubydoc.info/github/google/google-api-ruby-client/Google/Apis/DriveV3/DriveService。ここでは、ドキュメントを見ることができます –

0

:それはこのようになりますので、そのラインにあなたのフィールド値

type: "user", role: "writer" 

を追加してみてください正しいフォームそうな作品、そしてそれは誰もがGoogleのJavaScriptライブラリを使用している場合には、許可のフィールド名が権限構造のために作成

user_permission = {type: "user", role: "writer", email_address: "[email protected]"} 
@drive.create_permission(current_user.fileId, user_permission, send_notification_email: false, fields: 'id', &callback) 
0

だ私の作品人だけが「リソースであります'

関連する問題