gpt4 book ai didi

c# - 调用 PayPal 经典 API 服务时出错

转载 作者:太空宇宙 更新时间:2023-11-03 16:29:34 25 4
gpt4 key购买 nike

我正在尝试从我的 PayPal 账户中提取交易。我在沙盒环境中进行了一次成功的调用,但无法在现场复制。

我有一个 C# 控制台应用程序(针对框架 4)。我添加的服务是:https://www.paypal.com/wsdl/PayPalSvc.wsdl

这是我的代码(到目前为止显然只是概念证明):

 static void Main(string[] args)
{
using (var client = new PayPalService.PayPalAPIInterfaceClient())
{
var credentials = new PayPalService.CustomSecurityHeaderType
{
Credentials = new PayPalService.UserIdPasswordType
{
Username = "MyUsername",
Password = "MyPassword",
Signature = "MySignature"
}
};




TransactionSearchReq request = new TransactionSearchReq();

request.TransactionSearchRequest = new TransactionSearchRequestType();


request.TransactionSearchRequest.StartDate = DateTime.Now.AddHours(-12);

request.TransactionSearchRequest.EndDate = DateTime.Now;

TransactionSearchResponseType transactionSearchResponseType = client.TransactionSearch(ref credentials, request);

}

}

端点

            <endpoint address="https://api.paypal.com/2.0/" binding="wsHttpBinding"
bindingConfiguration="PayPalAPISoapBinding" contract="PayPayService.PayPalAPIInterface"
name="PayPalAPI" />

当我进行调用时(代码的最后一行)出现错误:

An error occurred while receiving the HTTP response to https://api.paypal.com/2.0/. This could be due to the service endpoint binding not using the HTTP protocol. This could also be due to an HTTP request context being aborted by the server (possibly due to the service shutting down). See server logs for more details.

我已经搜索了答案,但没有找到任何解决问题的方法。我需要做的就是下载交易,不需要其他功能。

最佳答案

您是否检查过您是否将请求发送到正确的端点?

此处有更多详细信息:https://developer.paypal.com/webapps/developer/docs/classic/api/endpoints/

更新:看起来端点确实是你的问题。您的代码使用了用户名、密码和签名,但随后您将端点设置为证书端点而不是签名端点。

关于c# - 调用 PayPal 经典 API 服务时出错,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26238624/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com