PayPal is returning a 414 "Request-URI Too Large" error when requesting POST to verify a data received. Admittedly, the data we have is too long but we couldn't do anything with that since it is a valid transaction from our customer. I have referred this to PayPal, but the thing is PayPal said that we sent a GET request instead of a POST request which i could not find anywhere in the program. Our program explicitly set the method to POST, below is the codes. Please note that our IPN listener is working fine and this error is particular to a specific notification only. I'm lost here, i couldn't find anything wrong with our program.
Try
'gather the info
Dim strContent As String = String.Empty
Using reader = New StreamReader(Request.InputStream)
strContent = reader.ReadToEnd()
End Using
mstrActualContent = strContent
ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12
'create webrequest - https://developer.paypal.com/api/nvp-soap/ipn/IPNIntro/
Dim hwrIPNVerify As HttpWebRequest = DirectCast(WebRequest.Create(HelperClasses.PayPal.IPNVerifyUrl & "?" & mcVerifyIPNPrefix & strContent), HttpWebRequest)
hwrIPNVerify.UserAgent = "ASP-IPN-ipnlistener"
hwrIPNVerify.Method = WebRequestMethods.Http.Post
hwrIPNVerify.ContentType = "application/x-www-form-urlencoded"
'post
Dim hwrIPNVerifyResp As HttpWebResponse = DirectCast(hwrIPNVerify.GetResponse(), HttpWebResponse)
Using oStreamReader = New StreamReader(hwrIPNVerifyResp.GetResponseStream())
mstrResponse = oStreamReader.ReadToEnd()
End Using
If mstrResponse = "VERIFIED" Then
'process data
Else
'log error
End If
Catch ex As Exception
Throw
End Try
CodePudding user response:
You are appending data to the URL, which is normally only done for GET requests. Even though you are sending an HTTP requst of type post, the issue is that all the data is in the URL string after a ?
.
That data is too long. You need to put the data (strContent
in your code) in the request's POST body rather than the URL.