LWP :: Authen :: OAuth2でPerlを使用してGoogleチームドライブの作成を実行しようとしています。google Drive APIを使用してgoogleチームドライブを作成することを理解します。1requestId
つのパラメーターと別のjson本体を投稿する必要がありますname
(参照:https://developers.google.com/drive/api/v3/reference/teamdrives/create)
しかし、私はエラーコード400とエラーメッセージを受け取り続けます
チームドライブ名を指定する必要があります。空ではなく、完全に空白ではありません。
これは、のjson本文がname
正しく投稿されていないことを示しています。
以下は私のコードです:
# Go get the auth tokens
$oauth2->request_tokens(code => $code);
my $requestID = "randomrequestID";
my $json = '{"name": "anyteamdrivename"}';
my $resp = $oauth2->post("https://www.googleapis.com/drive/v3/teamdrives?requestId=$requestID, Content-Type => application/json, Content => $json");
my $data = decode_json($resp->content());
use Data::Dumper;
print Dumper $data;
Perlの知識を持っている人が光を遮ることができるかどうかを感謝します。
呼び出しでパラメータを正しく渡していない->post
:
my $resp = $oauth2->post("https://www.googleapis.com/drive/v3/teamdrives?requestId=$requestID, Content-Type => application/json, Content => $json");
Content-Typeから始まるすべてのものを文字列から移動します。
my $resp = $oauth2->post(
"https://www.googleapis.com/drive/v3/teamdrives?requestId=$requestID",
"Content-Type" => "application/json",
"Content" => $json
);
メソッドに関するLWP :: UserAgentのドキュメントも参照してください->post
。
この記事はインターネットから収集されたものであり、転載の際にはソースを示してください。
侵害の場合は、連絡してください[email protected]
コメントを追加