相关疑难解决方法(0)

PayPal API Http调用问题

我已经为用户集成了一个选项,通过PayPal在我正在创建的网上商店进行在线购物.当我开始收到此错误时突然出现问题:

You must write ContentLength bytes to the request stream before calling [Begin]GetResponse. 
Run Code Online (Sandbox Code Playgroud)

Http调用的代码如下:

   public string HttpCall(string NvpRequest)
        {
            string url = pEndPointURL;

            string strPost = NvpRequest + "&" + buildCredentialsNVPString();
            strPost = strPost + "&BUTTONSOURCE=" + HttpUtility.UrlEncode(BNCode);

            HttpWebRequest objRequest = (HttpWebRequest)WebRequest.Create(url);
            objRequest.Timeout = Timeout;
            objRequest.Method = "POST";
            objRequest.ContentLength = strPost.Length;

            try
            {
                using (StreamWriter myWriter = new StreamWriter(objRequest.GetRequestStream()))
                {
                    myWriter.Write(strPost.ToString());
                }
            }
            catch (Exception e)
            {

            }

            //Retrieve the Response returned from the NVP API call to PayPal. 
            HttpWebResponse …
Run Code Online (Sandbox Code Playgroud)

c# asp.net paypal httpwebrequest httpwebresponse

4
推荐指数
1
解决办法
2745
查看次数

标签 统计

asp.net ×1

c# ×1

httpwebrequest ×1

httpwebresponse ×1

paypal ×1