|We don't bite newbies here... much|
HTTP::Tiny losing headers for Stripeby Bod (Priest)
|on Jun 25, 2022 at 20:32 UTC||Need Help??|
Bod has asked for the wisdom of the Perl Monks concerning the following question:
I'm trying to update a subscription in Stripe.
This involves calling an API with an authorisation header using POST. If the payload is empty, the API returns a JSON object representing the existing subscription. If there is subscription data in the payload, Stripe attempts to update the subscription and returns the complete subscription object. Pretty straightforward and it all works fine. Until I need to read the existing subscription object and then update it.
I have hit a problem and I can't think of how to debug it further!
With the code as it is, I get an error from Stripe that I have not supplied an API key. The key is in the $headers variable. If I take out the first call to Stripe, the one with the empty payload, then the second one succeeds * so the API key is working fine in this case. But as soon as I make two calls, it fails.
Things I've tried but haven't helped:
It is as if HTTP::Tiny doesn't like making consecutive POSTs but I cannot find anything in the documentation about this.
* - Without the first call, the second call to Stripe gives an error because I haven't got the parameters right. But it doesn't complain about there not not being an API key