UpdateRecurringPaymentsProfile +身份验证/授权失败

时间:2015-08-19 12:23:08

标签: c# asp.net rest asp.net-web-api paypal

我尝试使用

中的UpdateRecurringPaymentsProfile在Paypal中发出请求HttpWebRequest

MVC webapplication。但处理此请求时出现问题。

请参阅我的以下结果。

  

TIMESTAMP = 2015-08-19T12:07:38Z& CORRELATIONID = c803523ed08bf& ACK = Failure& VERSION = 0.000000& BUILD = 000000& L_ERRORCODE0 = 10002& L_SHORTMESSAGE0 =认证/授权失败& L_LONGMESSAGE0 =您没有权限进行此API调用& L_SEVERITYCODE0 =错误

HttpWebRequest request = (HttpWebRequest)WebRequest.Create("https://api-3t.sandbox.paypal.com/nvp");

        request.Method = "POST";

        string formContent =
                "&METHOD=UpdateRecurringPaymentsProfile" +
                "&PROFILEID=" + HttpContext.Current.Session["profileid"] +
                "&AMT=" + amt +
                "&CURRENCYCODE=" + currencycode +
                "&ACCT" + acct +
                "&FIRSTNAME=" + firstname +
                "&LASTNAME=" + lastname +
                "&STREET=" + street +
                "&CITY=" + city +
                "&STATE=" + state +
                "&COUNTRYCODE=" + countrycode +
                "&ZIP=" + zip;

        byte[] byteArray = System.Text.Encoding.UTF8.GetBytes(formContent);
        request.ContentType = "application/x-www-form-urlencoded";
        request.ContentLength = byteArray.Length;
        System.IO.Stream dataStream = request.GetRequestStream();
        dataStream.Write(byteArray, 0, byteArray.Length);
        dataStream.Close();
        WebResponse response = request.GetResponse();
        dataStream = response.GetResponseStream();
        System.IO.StreamReader reader = new System.IO.StreamReader(dataStream);

        string responseFromServer = System.Web.HttpUtility.UrlDecode(reader.ReadToEnd());

        reader.Close();
        dataStream.Close();
        response.Close();

我已成功完成CreateRecurringPaymentsProfile命令。

0 个答案:

没有答案