Delphi 与Indy一起发送的JSON不会被接收,因为它是由Stripe API发送的

Delphi 与Indy一起发送的JSON不会被接收,因为它是由Stripe API发送的,delphi,indy,Delphi,Indy,我正在向条带API发送一个带有Indy http组件的JSON,但API没有接收到它,因为它是在我收到“错误请求”响应时接收的: jsnObj:=TJSONObject.Create; jsnObj.AddPair('amount',TJSONNumber.Create('111'); jsnObj.AddPair(“货币”、“欧元”); jsnObj.AddPair('customer','cus_JNxQsqf6BoK8Rt'); AddPair('description','My Firs

我正在向条带API发送一个带有Indy http组件的JSON,但API没有接收到它,因为它是在我收到“错误请求”响应时接收的:

jsnObj:=TJSONObject.Create;
jsnObj.AddPair('amount',TJSONNumber.Create('111');
jsnObj.AddPair(“货币”、“欧元”);
jsnObj.AddPair('customer','cus_JNxQsqf6BoK8Rt');
AddPair('description','My First Test');
ss:=TStringStream.Create(jsnObj.ToString,TEncoding.UTF8);
rs:=TStringStream.Create;
IdHTTP1.Request.BasicAuthentication:=True;
IdHTTP1.Request.Username:=ApiKey;//测试私钥
IdHTTP1.Post('https://api.stripe.com/v1/charges",ss,rs),;
StatusBar1.SimpleText:=IdHTTP1.ResponseText;
要发送的JSON是:

{
“金额”:111,
“货币”:“欧元”,
“客户”:“客户JNxQsqf6BoK8Rt”,
“描述”:“我的第一次测试”
}
API仪表板报告已收到以下信息:

{
“{”金额“:111”,货币“:”欧元“,”客户“:”客户“,”说明“:”我的第一次测试“}”:空
}
HTTP组件应该制作一些东西,以便以这种方式发送,包括空值,可能是因为请求中包含用户名?对于其他API,相同的HTTP组件总是发送它要发送的内容。条带支持表明问题出在我这边。 条带文档指定了以下内容:

curl-X POSThttps://api.stripe.com/v1/charges \
-u STRIPE_SECRET_密钥:\
-d数额=2000\
-d货币=美元\
-d来源=托克尤签证\
-d description=“艾登的费用。jones@example.com"

有人知道问题出在哪里吗?

Stripe文档中提供的CURL示例根本没有以JSON格式发送数据。它以
application/x-www-form-urlencoded
格式发送
name=value
对,具体如下:

-d、 --数据

(HTTP MQTT)将POST请求中的指定数据发送到HTTP服务器,其方式与用户填写HTML表单并按下提交按钮时浏览器的方式相同这将导致curl使用内容类型application/x-www-form-urlencoded将数据传递给服务器。与…相比

发布
应用程序/x-www-form-urlencoded
请求时,请使用
TIdHTTP.Post()
TStrings
重载,例如:

var
postData:TStringList;
rs:字符串;
...
postData:=TStringList.Create;
尝试
postData.Add('amount=111');
postData.Add('currency=eur');
添加('customer=cus_JNxQsqf6BoK8Rt');
Add('description=My First Test');
IdHTTP1.Request.BasicAuthentication:=True;
IdHTTP1.Request.Username:=ApiKey;//测试私钥
rs:=IdHTTP1.Post('https://api.stripe.com/v1/charges,postData);
StatusBar1.SimpleText:=IdHTTP1.ResponseText;
最后
postData.Free;
结束;

这就是解决方案,它解决了它。谢谢。。