0

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

1 Answer 1

1

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.

3
  • but isn't it the requirement from PayPal? If it is supposed to be in the body, I wonder why other notifications were being verified successfully?
    – sd4ksb
    Commented Dec 20, 2022 at 18:34
  • A GET string is supported for legacy integrations that still use it, but the data cannot be too long for the URL. The PayPal documentation says to use POST developer.paypal.com/api/nvp-soap/ipn/IPNImplementation Commented Dec 20, 2022 at 18:47
  • I got! This example from their web page caused confusion to me, developer.paypal.com/api/nvp-soap/ipn/IPNIntro/#c2cb-target-1. i thought i have to append the data to the URL. Thanks for the clarification.
    – sd4ksb
    Commented Dec 20, 2022 at 19:11

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.