【发布时间】:2012-03-20 07:47:12
【问题描述】:
我正在关注 Dwolla 的 docs 服务器到服务器方法,并在正文中使用以下 json 数据向文档中的 URL 发出发布请求:
{
"Key":"Fake_Key",
"Secret":"Fake_Secret",
"PurchaseOrder":{
"DestinationId":"Fake_Destination_id",
"Discount":0,
"OrderItems":[
{
"Description":"a product",
"Name":"lol",
"Price":19.99,
"Quantity":20
}
]
},
"Shipping":0,
"Tax":0,
"Total":399.8,
"Test":true
}
不幸的是,虽然数据对我来说似乎有效,但他们的服务器正在响应错误消息:
{
"Result":"Failure",
"Message":"Total cannot be less than $1."
}
虽然错误告诉我问题在于“总计”小于 1 美元,但显然不是。
-- 更多信息
这是我用来发出请求的 php:
$result = file_get_contents('https://www.dwolla.com/payment/request', null, stream_context_create(array(
'http' => array(
'method' => 'POST',
'header' => 'Content-Type: application/json' . "\r\n" .
'Content-Length: ' . strlen(json_encode($body)) . "\r\n",
'content' => json_encode($body),
),
)));
当我推荐 Content-Type 时,我得到“无效的应用程序凭据”作为错误。
【问题讨论】:
标签: json api rest response dwolla