To be clear, what I am trying to acheive is:
Have my Paypal current balance show up in a textbox on VB.NET using the PayPal API
Not a VB.Net Webbrowser

I have followed the guide on this page

But I keep getting the error
Object reference not set to an instance of an object.

when I execute this code in VB.NET:
Imports PayPalAPITest.com.paypal.www

Public Class Form1

Private Sub btnGetBalance_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnGetBalance.Click
Dim credentials As New UserIdPasswordType
credentials.Username = "*********_"
credentials.Password = "****************"
credentials.Signature = "****************.****************-****************"
credentials.Subject = "****************@********."

Dim customSecurityHeader As New CustomSecurityHeaderType
customSecurityHeader.Credentials = credentials

Dim ServiceInterface As New PayPalAPISoapBinding
ServiceInterface.Url = ""
ServiceInterface.RequesterCredentials = customSecurityHeader

Dim request As New GetBalanceRequestType
request.Version = "59.0"

Dim req As New GetBalanceReq
req.GetBalanceRequest = request

Dim response As GetBalanceResponseType
response = ServiceInterface.GetBalance(req)

Me.txtBalance.Text = response.Balance.Value
End Sub
End Class

Has anyone managed to get this to work??
If so, please lend a hand

Dani AI

Generated

A short diagnosis and practical checklist for (building on ’s tip about the WSDL version).

A NullReference at the line that reads the balance usually means the SOAP call returned no Balance element (or the entire response was Nothing) because the API call failed or returned an error instead of a successful GetBalance payload. The GetBalance SOAP response only contains a Balance/BalanceHoldings when the call succeeds, so you must inspect the response status and any error elements before dereferencing the Balance node. (developer.paypal.com)

Immediate checks (fast wins)

  • Confirm you are using the correct endpoint for your credential type (signature vs certificate) and that you’re calling sandbox vs live appropriately — a credentials/endpoint mismatch commonly causes authentication failures and empty results. (developer.paypal.com)
  • Make sure your account and credentials are allowed to call GetBalance (this operation is available to classic API users and business/merchant accounts in the classic flow). (paypal.com)

How to debug (practical steps)

  • Capture the raw SOAP request/response (Fiddler, WireShark, or .NET message logging) and confirm the server returned a SOAP fault or an Errors array; do not assume the call succeeded.
  • Check the WSDL ns:version (the generated proxy can be out of sync with PayPal’s current API version) — regenerate your proxy/web reference from the correct WSDL if versions differ. (stackoverflow.org.cn)

Minimal VB.NET pattern to avoid the crash

Try
  Dim resp = ServiceInterface.GetBalance(req)
  If resp Is Nothing OrElse resp.Balance Is Nothing Then
    ' Log full SOAP response / resp.Errors and stop
  Else
    txtBalance.Text = resp.Balance.Value
  End If
Catch ex As Exception
  ' Log ex.Message / ex.InnerException / HTTP status
End Try

If starting fresh or you need a more robust, supported endpoint, consider PayPal’s newer reporting/REST balance endpoints instead of classic SOAP; they return balances in JSON and use OAuth2 tokens. (developer.paypal.com)

Suggested next steps: enable request/response capture, confirm endpoint vs credential type, inspect resp.Errors or SOAP fault, check WSDL/ns:version and regenerate your proxy, then add the defensive null checks above.

That blog was written in 2008, perhaps they have made some updates since then.
I noticed in one of the comments below that "request.Version" has another value.

If you take a look in "PayPalSvc.wsdl" and locate the entry "ns:version" you might find the correct value to use.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.