I apologize for asking a question about a 7 year old application, but Microsoft wrote it, and I thought it would be bug-free. Ha!
In their example of a webstore, they offer the following code:
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;
//Retrieve the Response returned from the NVP API call to PayPal.
HttpWebResponse objResponse = (HttpWebResponse)objRequest.GetResponse();
But on the last line (just above), there's an error that I know nothing about:
System.Net.ProtocolViolationException: 'You must provide a request body if you set ContentLength>0 or SendChunked==true. Do this by calling [Begin]GetRequestStream before [Begin]GetResponse.'
This exception was originally thrown at this call stack:
System.Net.HttpWebRequest.GetResponse()
PayPal_Test.NVPAPICaller.HttpCall(string) in PayPalFunctions.cs
PayPal_Test.NVPAPICaller.ShortcutExpressCheckout(string, ref string, ref string) in PayPalFunctions.cs
PayPal_Test.Default.Page_Load(object, System.EventArgs) in Default.aspx.cs
System.Web.Util.CalliEventHandlerDelegateProxy.Callback(object, System.EventArgs)
System.Web.UI.Control.OnLoad(System.EventArgs)
System.Web.UI.Control.LoadRecursive()
System.Web.UI.Page.ProcessRequestMain(bool, bool)
Do you know if there's anything I can do about this?