I´m trying to test my IPN listener with the IPN simulator, but I´m always getting "Bad Request" error.
I´ve already see this answers:
PayPal IPN Bad Request 400 Error
Paypal SandBox IPN always returns INVALID
For my web I´m using the code you can find here: http://www.markstraley.com/Code/PayPalIPN
Thinking in the others answers, maybe there is something wrong in this code, but I don´t know what, if there is something wrong:
HttpWebRequest webRequest = (HttpWebRequest)WebRequest.Create(url);
webRequest.Method = "POST";
webRequest.ContentType = "application/x-www-form-urlencoded";
//must keep the original intact and pass back to PayPal with a _notify-validate command
string data = Encoding.ASCII.GetString(parameters);
data += "&cmd=_notify-validate";
webRequest.ContentLength = data.Length;
//Send the request to PayPal and get the response
using (StreamWriter streamOut = new StreamWriter(webRequest.GetRequestStream(),System.Text.Encoding.ASCII))
I´ve thought in this code section, because I saw that the other asnwers was solved with the header of the request, but I don´t know if this code is correct or not for PayPal. I´ve already seen the paypal code examples, but all of them are with VB or webforms.
Thank you for your help.
Note: I have my app in a server to test it, I´m not trying to call my localhost from the IPN simulator.
At the end, I simulated myself the post data from PayPal using the app "Advanced Rest Client" for Chrome: https://chrome.google.com/webstore/detail/advanced-rest-client/hgmloofddffdnphfgcellkdfbfbjeloo
I wanted to tested from PayPal, but for now it's enough. Thank you to Matt for this answer: http://stackoverflow.com/a/19941501