API请求问题

时间:2019-05-12 09:21:10

标签: perl coinbase-api

am解析coinbase api。但出现错误

我不知道错误来自哪里

因为所有字段我都可以看到

并且正在发送良好的json格式

喜欢发布有效信息

这是我运行代码时遇到的错误

{"error":{"type":"invalid_request","message":"Requested info must specify desired customer info fields"}}

硬币基本API

curl https://api.commerce.coinbase.com/checkouts \
     -X POST \
     -H 'Content-Type: application/json' \
     -H "X-CC-Api-Key: <Your API Key>" \
     -H "X-CC-Version: 2018-03-22"
     -d '{
         "name": "The Sovereign Individual",
         "description": "Mastering the Transition to the Information A
+ge",
         "local_price": {
             "amount": "100.00",
             "currency": "USD"
         },
       "pricing_type": "fixed_price",
         "requested_info": ["email"]
     }'

我的perl代码

#!/usr/bin/perl -w

use HTTP::Request::Common qw(POST);
use HTTP::Tinyish;
use LWP::UserAgent;
use JSON::XS;
use Net::SSL;
use CGI::Carp qw(fatalsToBrowser warningsToBrowser);


my $ua = LWP::UserAgent->new( ssl_opts => { verify_hostname => 0 }, );
$ua->agent("MyApp/0.1");


my $http = HTTP::Tinyish->new();

my $url = "https://api.commerce.coinbase.com/checkouts";
my $json = encode_json {
    name => 'John',
    description=> 'Hello',
    local_price => {
             amount => '100.00',
             currency => 'USD'
         },
    pricing_type=> 'fixed_price'

};


my $response = $http->post( $url => {
    content => $json,
    headers => { 'Content-Type' => 'application/json', 'X-CC-Api-Key' 
+=> '677423747324832434', 'X-CC-Version' => '2018-03-22' },
});

if ($response) {
print "$response->{content}\n";
}

0 个答案:

没有答案