我正在尝试将Perl与LWP :: Authen :: OAuth2结合使用来执行Google团队驱动器的创建。了解如何使用Google Drive API创建Google Team Drive,它需要发布1个参数requestId
和另一个json正文name
(参考:https://developers.google.com/drive/api/v3/reference/teamdrives/create)
但是,我不断收到错误代码400和错误消息,说
必须提供Team Drive名称,不能为空,也不能完全为空格。
表明name
的json正文未正确发布。
下面是我的代码:
# 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知识的人是否能够遮挡某些光线。
答案 0 :(得分:3)
您没有正确将调用中的参数传递给Sending build context to Docker daemon 4.608kB
Step 1/10 : FROM ubuntu:18.04
---> ea4c82dcd15a
Step 2/10 : RUN apt-get update
---> Using cache
---> 60e7c61ea78c
Step 3/10 : RUN apt-get install git -y
---> Using cache
---> 50a4def0607e
Step 4/10 : RUN git clone https://code.qt.io/qt/qt5.git /cloned-qt
---> Using cache
---> 97fb8ab6dc15
Step 5/10 : RUN cd /cloned-qt/
---> Running in 9be03fba40fa
Removing intermediate container 9be03fba40fa
---> 130bc457eb66
Step 6/10 : RUN git checkout 5.11
---> Running in 35de823fdf9c
fatal: not a git repository (or any of the parent directories): .git
:
->post
从Content-Type开头的所有内容移出字符串:
my $resp = $oauth2->post("https://www.googleapis.com/drive/v3/teamdrives?requestId=$requestID, Content-Type => application/json, Content => $json");
另请参见my $resp = $oauth2->post(
"https://www.googleapis.com/drive/v3/teamdrives?requestId=$requestID",
"Content-Type" => "application/json",
"Content" => $json
);
方法上的LWP::UserAgent文档。