You should compare what curl sends with what you send.

Invoke curl with -v -v -v to see what it sends over the wire.

Look at that.

Look at your script and the parameters you give it, and look at the API documentation for the API.

When I run your code through my Curl to Perl converter, I get the following:

#!perl use strict; use warnings; use HTTP::Tiny; my $ua = HTTP::Tiny->new( 'verify_SSL' => '1' ); my $res = $ua->request( 'POST' => 'https://api.link.io/v1/payment', { headers => { 'Accept' => '*/*', 'User-Agent' => 'curl/7.55.1', 'Content-Length' => '196', 'Content-Type' => 'application/json', 'X-Api-Key' => '{{api-key}}' }, content => "{ \x22price_amount\x22: 3999.5, \x22price_currency\x22: \x22usd\x22 +, \x22pay_currency\x22: \x22usd\x22, \x22ipn_callback_url\x22: \x22 +https://link.io\x22, \x22order_id\x22: \x22RGDBP-21314\x22, \x22ord +er_description\x22: \x22Apple Macbook Pro 2019 x 1\x22}" }, );

Most likely, the API does not want {{ABCDEF}} but ABCDEF in its x-api-key header.


In reply to Re: curl url request by Corion
in thread curl url request by frank1

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.