我需要验证使用移动设备完成的PayPal付款,但它总是返回 java.lang.NullPointerException 错误
C#代码
// Get a reference to the config
var config = ConfigManager.Instance.GetProperties();
// Use OAuthTokenCredential to request an access token from PayPal
var accessToken = new OAuthTokenCredential(config).GetAccessToken();
var apiContext = new APIContext(accessToken);
var PayID = "PAY-6PU626847B294848Y6KEWXHY";
var payment = Payment.Get(apiContext, PayID);
远程服务器返回错误:(404)Not Found。
答案 0 :(得分:0)
我得到了解决方案,标题信息丢失了
var apiContext = new APIContext(accessToken);
if (apiContext.HTTPHeaders == null)
{
apiContext.HTTPHeaders = new Dictionary<string, string>();
apiContext.HTTPHeaders.Add("Content-Type", "application/json");
apiContext.HTTPHeaders.Add("Authorization", accessToken);
}
谢谢