Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister
 
PerlMonks  

Re^3: post JSON using HTTP::Tiny - cannot parse URL

by GertMT (Hermit)
on Apr 23, 2020 at 20:16 UTC ( #11115973=note: print w/replies, xml ) Need Help??


in reply to Re^2: post JSON using HTTP::Tiny - cannot parse URL
in thread post JSON using HTTP::Tiny - cannot parse URL

alright with the following code I got it to work.
Thanks!
sub create_external_inv { my $agent = HTTP::Tiny->new; my $headers = { Accept => "application/json", 'Content-Type' => "application/json", Authorization => "Bearer 123" }; my $url = "https://moneybird.com/api/v2/123/external_sales_invoices"; my $data = { external_sales_invoice => { "reference" => "M-8426", "date" => "2020-03-14", "contact_id" => 456, "details_attributes" => [ { "description" => "coffee", "price" => 2.25, "tax_rate_id" => 891, } ] } }; my $res = $agent->post( $url => { content => to_json($data), headers => $headers } ); print Dumper $res; if ( $res->{success} ) { print "Okay!\n"; } else { print "\n\nNope...\n\n"; } }
The results print okay!.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://11115973]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others exploiting the Monastery: (3)
As of 2021-10-23 20:21 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    My first memorable Perl project was:







    Results (88 votes). Check out past polls.

    Notices?