in reply to HTTP::Tiny losing headers for Stripe
You will also need to set the "content-type" header to "application/json" and use the request() method instead of post_form() as the latter only sends "application/x-www-form-urlencoded" (at least that what the docs seem to be saying)
my $subscription = { 'items[0][id]' => 'x', 'items[0][price]' => 'some price', }; my $options = { 'headers' => { 'Authorization' => 'Bearer ' . $Site::Variables::stripe_secret +, 'content-type' => 'application/json', }, 'content' => encode_json($subscription), }; my $response = $http->request('POST', "https://api.stripe.com/v1/subsc +riptions/$sub_id", $options);
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: HTTP::Tiny losing headers for Stripe
by Bod (Parson) on Jun 25, 2022 at 22:27 UTC | |
by tangent (Parson) on Jun 26, 2022 at 00:23 UTC | |
by Bod (Parson) on Jun 26, 2022 at 09:45 UTC |