http://qs321.pair.com?node_id=11115959


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

Thank you for the reference and I promise to look at the tests more often. Very helpful.

I didn't get it to work yet and will post later when I've solved it.

  • Comment on Re^2: post JSON using HTTP::Tiny - cannot parse URL

Replies are listed 'Best First'.
Re^3: post JSON using HTTP::Tiny - cannot parse URL
by GertMT (Hermit) on Apr 23, 2020 at 20:16 UTC
    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!.