I'm trying to hack a perl module that uses mojolicious to make api calls to google's api so that it can make batch api call as documented here: https://developers.google.com/gmail/api/guides/batch
I've made various attempts but no calls are resulting in a successful
response. Here's what I'm currently trying.
my $options =
[
{
content => 'GET
/gmail/v1/users/[email protected]/messages/165e91c27e4af0be',
'Content-Type' => 'application/http',
},
{
content => 'GET
/gmail/v1/users/[email protected]/messages/165e94ce49900df2',
'Content-Type' => 'application/http',
}
];
my $path = 'https://www.googleapis.com/batch/' . $s->api . '/' . $s->
version;
my $headers = {'Authorization' => 'Bearer TOKEN_HERE'};
$tx = $self->ua->build_tx(
uc $http_method => $path => $headers => json => $optional_data
);
This results in a tranaction object that looks like this:
$VAR1 = bless( {
'req' => bless( {
'content' => bless( {
'headers' => bless(
{
'headers' => {
'content-type' => [
'application/json'
],
'authorization' => [
'Bearer TOKEN_HERE'
],
'accept-encoding' => [
'gzip'
],
'user-agent' => [
'Mojolicious (Perl)'
]
}
}, 'Mojo::Headers' ),
'events' => {
'read' => [
sub { "DUMMY" }
]
},
'read' => $VAR1->{
'req'}{'content'}{'events'}{'read'}[0],
'asset' => bless( {
'content' => '[{"Content-Type":"application\\/http","content":"GET
\\/gmail\\/v1\\/u
sers\\/[email protected]\\/messages\\/165e91c27e4af0be"},{"Content-Type":"application\\/http","content":"GET
\\/gmail\\/v1\\/users\\/[email protected]\\/messag
es\\/165e94ce49900df2"}]'
}, 'Mojo::Asset::Memory' )
},
'Mojo::Content::Single' ),
'url' => bless( {
'scheme' => 'https',
'host' =>
'www.googleapis.com',
'path' => bless( {
'path' => '/batch/gmail/v1'
},
'Mojo::Path' )
}, 'Mojo::URL' ),
'method' => 'POST'
}, 'Mojo::Message::Request' )
}, 'Mojo::Transaction::HTTP' );
Trying anything other than json for the generator results in an error:
Use of uninitialized value $cb in method lookup
Fiddling with the content type settings doesn't help make this go away.
--
You received this message because you are subscribed to the Google Groups
"Mojolicious" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/mojolicious.
For more options, visit https://groups.google.com/d/optout.
