Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW
 
PerlMonks  

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

by GertMT (Hermit)
on Apr 23, 2020 at 20:16 UTC ( [id://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?Last hourOther CB clients
Other Users?
Others wandering the Monastery: (2)
As of 2024-04-25 21:03 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found