Because content-type' => 'application/json' you have to json encode the content
poj#!/usr/bin/perl use strict; use warnings; use HTTP::Request::Common qw( POST ); use LWP::UserAgent; use Encode qw(encode_utf8); use JSON::MaybeXS qw(encode_json); my $ua = LWP::UserAgent->new; my $data = { '401k_contributions' => 0, business_income => 0, charity_contributions => 0, child_dep => 2, filing_status => 2, interest_paid => 0, medical_expenses => 0, nonchild_dep => 0, ordinary_income1 => 150000, ordinary_income2 => 0, other_itemized => 0, qualified_income => 0, sl_income_tax => 0, sl_property_tax => 0, ss_income => 0, }; my $content = encode_utf8(encode_json($data)); my $req = POST 'https://tax-calculator-api.taxfoundation.org/taxcalc/t +cja_submit', Host => 'tax-calculator-api.taxfoundation.org', Connection => 'keep-alive', Origin => 'https://taxfoundation.org', 'User-Agent' => 'Mozilla/5.0 (Windows NT 10.0; Win64; x64 +) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/69.0.3497.100 Safari/ +537.36', 'content-type' => 'application/json', Accept => '*/*', Referer => 'https://taxfoundation.org/2018-tax-refor +m-calculator/', 'Accept-Encoding' => 'gzip, deflate, br', 'Accept-Language' => 'en-US,en;q=0.9', Content => $content ; #print $req->as_string; print $ua->request($req)->as_string;
In reply to Re^3: Runs from Command Line but NOT from Perl
by poj
in thread Runs from Command Line but NOT from Perl
by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |