HttpWebRequest用paypal参数发送POST数据? [英] HttpWebRequest to send POST data with paypal parameters?

查看:142
本文介绍了HttpWebRequest用paypal参数发送POST数据?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



当我使用以下代码行向paypal发送请求进行身份验证时,

Hi,
When I send a request to the paypal using following code lines for authentication,

HttpWebRequest objRequest = (HttpWebRequest)WebRequest.Create("https://api-3t.sandbox.paypal.com/nvp");
StringBuilder URLQueryString = new StringBuilder();
URLQueryString.Append("USER=bilal._1303994161_biz_api1.muskysoftware.com&");
URLQueryString.Append("PWD=somepassword&");
URLQueryString.Append("SIGNATURE=A3s7K7bICpflbySN2Fd3AlzTTbF1AZLBiCeUdtRindoV3BOytl-BKSsv&");
URLQueryString.Append("SUBJECT=Hello this a test&");
URLQueryString.Append("VERSION=56.0");
objRequest.Method = "POST";
objRequest.ContentLength = URLQueryString.Length;
objRequest.ContentType = "application/x-www-form-urlencoded";



我收到以下回复:




I get the following response:

ACK=Failure&L_ERRORCODE0=81002&L_SHORTMESSAGE0=Unspecified%20Method&L_LONGMESSAGE0=Method<br />
%20Specified%20is%20not%20Supported&L_SEVERITYCODE0=Error<br />





为什么会失败?请帮忙。



谢谢。



Why is it failing? Please help.

Thank you.

推荐答案

在您的错误回复中,您会看到以下文字:< br $>


方法%20指定%20is%20not%20支持



并且在你的代码中你有:



In your error response you see the following text:

Method%20Specified%20is%20not%20Supported

and in your code you have:

objRequest.Method = "POST";





尝试将该行更改为:< br $>




Try changing that line to:

objRequest.Method = "GET";





你要在URL中添加查询字符串变量,它们通常并不总是与Http GET相关联。



You''re adding querystring variables to the URL, they''re generally if not always associated with Http GET.


尝试这个并提供所需的信息,将其替换为你的详情



Try this and provide information that are required, replace it with your details

public string GetSubmitUrl()
{
      StringBuilder url = new StringBuilder();
      url.Append( this.PayPalBaseUrl + "cmd=_xclick&business="+
            HttpUtility.UrlEncode( AccountEmail ) );
      if( BuyerEmail != null && BuyerEmail != "" )
            url.AppendFormat( "&email={0}", HttpUtility.UrlEncode( BuyerEmail ) );
      if (Amount != 0.00M)
            url.AppendFormat("&amount={0:f2}", Amount);
      if( LogoUrl != null && LogoUrl != "" )
            url.AppendFormat( "&image_url={0}", HttpUtility.UrlEncode( LogoUrl ) );
      if( ItemName != null && ItemName != "" )
            url.AppendFormat( "&item_name={0}", HttpUtility.UrlEncode( ItemName ) );
      if( InvoiceNo  != null && InvoiceNo != "" )
            url.AppendFormat( "&invoice={0}", HttpUtility.UrlEncode( InvoiceNo ) );
      if( SuccessUrl != null && SuccessUrl != "" )
            url.AppendFormat( "&return={0}", HttpUtility.UrlEncode( SuccessUrl ) );
      if( CancelUrl != null && CancelUrl != "" )
            url.AppendFormat( "&cancel_return={0}", HttpUtility.UrlEncode( CancelUrl ) );
      return url.ToString();
}







希望有帮助




Hope it helps






错误的原因是:



URLQueryString.Append(VERSION = 56.0) ;



您没有提供最新的有效版本 - 尝试62以上的东西或向PayPal索取正确的版本。
Hi,

The error is caused by:

URLQueryString.Append("VERSION=56.0");

You are not supplying a recent valid version--try something over 62 or ask PayPal for a correct version.


这篇关于HttpWebRequest用paypal参数发送POST数据?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆