# keeping it simple with just one nested request. no improvement with more added here. my $options = [ { content => 'GET /gmail/v1/users/real_address@gmail.com/messages/165eb111fcf21503', 'Content-type' => 'application/http', # internal server error when set to 'application/json' }, ]; my $path = 'https://www.googleapis.com/batch/gmail/v1'; # this is the call to Moo Google's lower level api_query function. my $res = $s->_gapi->api_query( { httpMethod => 'POST', path => $path, options => $options, }); print Dumper $res; # then, over in Moo::Google we do some Mojolicious stuff with our api_query call # build the transactor (this function is in Moo::Google # $headers was created earlier and contains bearer token # $headers->{content-type} = 'mixed/multipart'; # tried this and many other content types with no improvement my $tx = $self->ua->build_tx( uc $http_method =>$path => $headers => multipart => $options); my $res = $self->ua->start($tx)->res; return $res; #### $VAR1 = bless( { 'req' => bless( { 'method' => 'POST', 'url' => bless( { 'scheme' => 'https', 'host' => 'www.googleapis.com', 'path' => bless( { 'path' => '/batch/gmail/v1' }, 'Mojo::Path' ) }, 'Mojo::URL' ), 'content' => bless( { 'events' => { 'read' => [ sub { "DUMMY" } ] }, 'headers' => bless( { 'headers' => { 'accept-encoding' => [ 'gzip' ], 'authorization' => [ 'Bearer REAL_TOKEN_GOES_HERE' ], 'user-agent' => [ 'Mojolicious (Perl)' ] } }, 'Mojo::Headers' ), 'parts' => [ bless( { 'read' => sub { "DUMMY" }, 'events' => { 'read' => [ $VAR1->{'req'}{'content'}{'parts'}[0]{'read'} ] }, 'asset' => bless( { 'content' => 'GET /gmail/v1/users/real_email@gmail.com/messages/165eb111fcf21503' }, 'Mojo::Asset::Memory' ), 'headers' => bless( { 'headers' => { 'content-type' => [ 'application/http' ] } }, 'Mojo::Headers' ) }, 'Mojo::Content::Single' ) ] }, 'Mojo::Content::MultiPart' ) }, 'Mojo::Message::Request' ) }, 'Mojo::Transaction::HTTP' ); #### $VAR1 = bless( { 'error' => { 'code' => '400', 'message' => 'Bad Request' }, 'events' => {}, 'finished' => 3, 'message' => 'Bad Request', 'code' => '400', 'state' => 'finished', 'version' => '1.1', 'raw_size' => 757, 'max_line_size' => 8192, 'content' => bless( { 'relaxed' => 1, 'chunk_state' => 'finished', 'post_buffer' => '', 'max_buffer_size' => 262144, 'raw_size' => 731, 'auto_decompress' => 1, 'state' => 'finished', 'header_size' => 365, 'chunk_len' => 0, 'gz' => bless( do{\(my $o = '140714715991136')}, 'Compress::Raw::Zlib::inflateStream' ), 'body' => 6, 'events' => { 'read' => [ sub { "DUMMY" } ] }, 'size' => 119, 'real_size' => 119, 'auto_relax' => 1, 'read' => $VAR1->{'content'}{'events'}{'read'}[0], 'headers' => bless( { 'headers' => { 'date' => [ 'Tue, 18 Sep 2018 15:04:56 GMT' ], 'x-xss-protection' => [ '1; mode=block' ], 'x-frame-options' => [ 'SAMEORIGIN' ], 'content-length' => [ 145 ], 'content-type' => [ 'text/html; charset=UTF-8' ], 'server' => [ 'GSE' ], 'x-content-type-options' => [ 'nosniff' ], 'alt-svc' => [ 'quic=":443"; ma=2592000; v="44,43,39,35"' ], 'cache-control' => [ 'private, max-age=0' ], 'expires' => [ 'Tue, 18 Sep 2018 15:04:56 GMT' ] }, 'max_lines' => 100, 'max_line_size' => 8192, 'state' => 'finished', 'names' => { 'x-xss-protection' => 'X-XSS-Protection', 'alt-svc' => 'Alt-Svc', 'x-frame-options' => 'X-Frame-Options', 'x-content-type-options' => 'X-Content-Type-Options' }, 'cache' => [] }, 'Mojo::Headers' ), 'asset' => bless( { 'content' => ' Bad Request

Bad Request

Error 400

', 'auto_upgrade' => 1, 'max_memory_size' => 262144 }, 'Mojo::Asset::Memory' ), 'auto_upgrade' => 1, 'buffer' => '' }, 'Mojo::Content::Single' ), 'max_message_size' => 2147483648 }, 'Mojo::Message::Response' ); ##
## POST /batch/gmail/v1 HTTP/1.1^M Accept-Encoding: gzip^M Host: www.googleapis.com^M User-Agent: Mojolicious (Perl)^M Content-Length: 120^M Content-Type: multipart/mixed; boundary=WHeuX^M Authorization: Bearer REAL_TOKEN^M ^M --WHeuX^M Content-Type: application/http^M ^M GET /gmail/v1/users/my_real_email@gmail.com/messages/165eb111fcf21503^M --WHeuX--^M