$client->POST ('https://api.sixfold.com/v1/companies/296/carrier-shipm
+ents/0005360404/allocation',
[
'{"type":"vehicle", "vehicle_id":"39257"
+}',
{Authorization => 'Bearer 096dd6e084d5f30fazzz', "Content-type" =>
+ 'application/json'}
]
);
REST::Client
=head3 POST ( $url, [$body_content, %$headers] )
Preform an HTTP POST to the resource specified. Takes an optional body
+ content and hashref of custom request headers.
=cut
Nope thats just indicating optional arguments, sorry.
There's some faffing with checking if the content is a scalar ref, maybe something to do with that?
update The content appears to be getting set from REST::Client. It's not passed in on the new so it is not set at construction time. Although the variable $http_req{_content} is set to the empty string at this time, so it exists.
The subroutine then queries if wantarray is defined. Although I don't think it is, if it is it will set the content and return the empty string. If not defined it will just set the content. If it is being called in void context it should Carp on global warnings being set so you'd be aware of that, also that would have been flagged before now I'm sure. Then it returns.
The set_content routine does a utf8_downgrade, but I don't think there are any problematic characters in that string. Then sets the string as the content.
Then it moves on to setting the headers and custom_headers, but you already said its not the headers.
So I can't see anything from reading through that would be a problem as such.
Aside from that, I was not sure exactly how the lc function in the auto getter/setter is working, and might ask someone to look at that for a second opinion.
update 2:From this point I could suggest sending a POST request from HTTP::Request directly and comparing the results, working back from there. HTTP::Request provides a dump routine, but its not documented so use at own risk.
#HTTP::Request POD
=head2 Simple POST
Here, we'll create a simple POST request that could be used to send JS
+ON data
to an endpoint.
#!/usr/bin/env perl
use strict;
use warnings;
use Encode qw(encode_utf8);
use HTTP::Request ();
use JSON::MaybeXS qw(encode_json);
my $url = 'https://www.example.com/api/user/123';
my $header = ['Content-Type' => 'application/json; charset=UTF-8']
+;
my $data = {foo => 'bar', baz => 'quux'};
my $encoded_data = encode_utf8(encode_json($data));
my $r = HTTP::Request->new('POST', $url, $header, $encoded_data);
# at this point, we could send it via LWP::UserAgent
# my $ua = LWP::UserAgent->new();
# my $res = $ua->request($r);
=cut
Maybe that can help you back engineer into the REST::Client framework to get the response you are after. Formatting the data using the encode routines suggested in the pod could be a good start.
|