Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6058903
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T08:39:05+00:00 2026-05-23T08:39:05+00:00

I have the 2 methods below, in a class, The Login Method works fine

  • 0

I have the 2 methods below, in a class, The Login Method works fine and retrieves and sets the session token, but in order for me to use GetEvents(), I have to send the sessionToken in the request for GetEvents().

But on the 4th Line of code (excluding Comments & Whitespace) of the getEvents(), I get the error: Object reference not set to an instance of an object.

 The Entire Source can be downloaded here: (Copy and Paste into your browser)
 http://www.theebookzone.co.uk/betfairui.zip

Any Ideas what Im doing wrong?
Any help appreciated, even if its not directly related to this matter.

public static string SessionToken = ""; // Set by Login();

static LoginResp Login()
    {
        // Make a new BFGS instance
        BFGlobal = new BFGlobalService.BFGlobalService();

        // Set up the request in [req]
        LoginReq req = new LoginReq();
        req.username = username;
        req.password = password;
        req.productId = productId;
        req.vendorSoftwareId = softwareId;

        // Set up the response in [resp]
        // Execute the call, and pass in the request
        LoginResp resp = BFGlobal.login(req);

        // Sets our public variable above to the recieved sessionToken
        SessionToken = resp.header.sessionToken;

        // return [resp] - which is the response from the call
        return resp;

    }

    public Array GetEvents()
    {
        // This will set the sessionToken declared at the top.
        LoginToBetfair();

        // Make a new instance of the web service
        BFGlobal = new BFGlobalService.BFGlobalService();

        // Load up the request
        GetEventsReq req = new GetEventsReq();

        // Error Line Below:
        req.header.sessionToken = SessionToken;  // <--- Here is where I get the error
        // Error Above Line: Object reference not set to an instance of an object.

        GetEventsResp resp = BFGlobal.getEvents(req);

        Array marketItems = resp.marketItems;

        return marketItems;

    }
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T08:39:06+00:00Added an answer on May 23, 2026 at 8:39 am

    I’d wager that the null object is the header of req.header. Put a break point at that line and then in the variables debugger window see what req.header evaluates to. If it is indeed null then you’ll have to manually add the headers with something like

    req.headers = new Headers();
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

We have a method that accesses a network share. This method works fine when
I have the below methods: public static byte[] ConvertFileToBytes(string filePath) { var fInfo =
I have a Controller with two Edit methods (see below). When I submit the
I have a WCF service and methods are exposed as below: public interface IService
I have the below method which is meant to append information to a file
I have a method to Generate Expression By Clause as below: internal static Expression<Func<TModel,
How can I select the good method (I have in the example below show
In C# I have methods that use [WebMethod(EnableSession = true)] I consume them in
In my application I have methods which returns a control (checkbox, radiobutton, textbox) but
I have a login form as below, I have tried doing this by onkeydown

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.