frank1 has asked for the wisdom of the Perl Monks concerning the following question:
i have the following api
curl --location 'https://api.link.io/v1/payment' \ --header 'x-api-key: {{api-key}}' \ --header 'Content-Type: application/json' \ --data '{ "price_amount": 3999.5, "price_currency": "usd", "pay_currency": "usd", "ipn_callback_url": "https://link.io", "order_id": "RGDBP-21314", "order_description": "Apple Macbook Pro 2019 x 1" }'
and am trying to parse it like this
#!/usr/bin/perl use strict; use warnings; use HTTP::Tiny; use JSON; use CGI::Carp qw(fatalsToBrowser warningsToBrowser); my $url = "https://api.link.io/v1/payment"; my $json = encode_json { price_amount => '10', price_currency => 'usd', pay_currency => 'usd', ipn_callback_url => 'https://link.com', order_id => 'RGDBP-21314', order_description => 'Apple Macbook Pro 2019 x 1' }; my $http = HTTP::Tiny->new(); my $response = $http->post( $url => { content => $json, headers => { 'x-api-key' => '{{MV34WM5Y8Y}}'}, headers => { 'Content-Type' => 'application/json' } }); print "Content-type: text/html\n\n"; if ( $response->{'is_success'} ) { print (decode_json $response->{'content'} ); } else { print "$response->{'status'} $response->{'content'}\n"; }
the response am getting is 403 {"status":false,"statusCode":403,"code":"INVALID_API_KEY","message":"Invalid api key"}
but the api key is valid, i think the problem is at the way i make my request
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: curl url request
by Corion (Patriarch) on May 24, 2024 at 13:23 UTC | |
by The_Dj (Scribe) on May 28, 2024 at 06:49 UTC | |
|
Re: curl url request
by hippo (Archbishop) on May 24, 2024 at 13:36 UTC | |
|
Re: curl url request
by sectokia (Friar) on Jun 04, 2024 at 04:54 UTC |