title: C# SteamBot - Get trade offer state
body: <p>I get error using this code:</p>
  
  <pre><code>var offer = Bot.NewTradeOffer(dbSteamId);
  
      offer.Items.AddMyItem(730, 2, 2611100148);
  
      if (offer.Items.NewVersion)
      {
          string newOfferId;
          if (offer.SendWithToken(out newOfferId, dbToken, dbMessage))
          {
              Log.Success("Trade offer sent : Offer ID " + newOfferId);
              Bot.TryGetTradeOffer(newOfferId, out offer);
          }
       }
  </code></pre>
  
  <p>It crashes with error:</p>
  
  <pre><code>ERROR: System.NullReferenceException: Object reference not set to an instance of an object. 
  at SteamTrade.TradeOffer.TradeOfferManager.IsOfferValid(Offer offer) in C:\Users\Robertas\Desktop\SteamBot-master\SteamTrade\TradeOffer\TradeOfferManager.cs:line 130
  at SteamTrade.TradeOffer.TradeOfferManager.GetOffer(String offerId, TradeOffer&amp; tradeOffer) in C:\Users\Robertas\Desktop\SteamBot-master\SteamTrade\TradeOffer\TradeOfferManager.cs:line 162
  at SteamBot.Bot.TryGetTradeOffer(String offerId, TradeOffer&amp; tradeOffer) in C:\Users\Robertas\Desktop\SteamBot-master\SteamBot\Bot.cs:line 331
  at SteamBot.TradeOfferUserHandler.SendTradeOffer() in C:\Users\Robertas\Desktop\SteamBot-master\SteamBot\TradeOfferUserHandler.cs:line 81
  at SteamBot.TradeOfferUserHandler.OnLoginCompleted() in C:\Users\Robertas\Desktop\SteamBot-master\SteamBot\TradeOfferUserHandler.cs:line 64
  at SteamBot.Bot.&lt;HandleSteamMessage&gt;b__5(LoginKeyCallback callback) in C:\Users\Robertas\Desktop\SteamBot-master\SteamBot\Bot.cs:line 476
  at SteamKit2.CallbackMsgExtensions.Handle[T](ICallbackMsg msg, Action`1 handler)
  at SteamBot.Bot.HandleSteamMessage(ICallbackMsg msg) in C:\Users\Robertas\Desktop\SteamBot-master\SteamBot\Bot.cs:line 458
  at SteamBot.Bot.BackgroundWorkerOnDoWork(Object sender, DoWorkEventArgs doWorkEventArgs) in C:\Users\Robertas\Desktop\SteamBot-master\SteamBot\Bot.cs:line 941
  </code></pre>
  
  <p>Any ideas? Maybe you know different way to check trade offer state? Please share your ideas. Thanks!</p>
  
  <p>EDITED:</p>
  
  <pre><code>public bool GetOffer(string offerId, out TradeOffer tradeOffer)
  {
      tradeOffer = null;
      var resp = webApi.GetTradeOffer(offerId);
      if (resp != null)
      {
          if (IsOfferValid(resp.Offer))
          {
              tradeOffer = new TradeOffer(session, resp.Offer);
              return true;
          }
          else
          {
              //todo: log steam api is giving us invalid offers.
              Console.WriteLine("Offer returned from steam api is not valid : " + resp.Offer.TradeOfferId);
          }
      }
      return false;
  }
  </code></pre>
  
  <p>resp.Offer is null. How can it be null? I could mention that everything works when bot send to my account, but when it sends to other account, it crashes.</p>
  
  <p>EDITED #2:</p>
  
  <p>Ok, I have found bug. It is problem by getting response. When i call this(<a href="http://api.steampowered.com/IEconService/GetTradeOffer/v1/?key=48B9FCE3FE8A74ADDA29174BFD47441B&amp;tradeofferid=530787948&amp;language=en_us" rel="nofollow">http://api.steampowered.com/IEconService/GetTradeOffer/v1/?key=48B9FCE3FE8A74ADDA29174BFD47441B&amp;tradeofferid=530787948&amp;language=en_us</a>):</p>
  
  <pre><code>{
  "response": {
  
  }
  </code></pre>
  
  <p>}</p>
  
  <p>When I call this(<a href="http://api.steampowered.com/IEconService/GetTradeOffer/v1/?key=48B9FCE3FE8A74ADDA29174BFD47441B&amp;tradeofferid=530796219&amp;language=en_us" rel="nofollow">http://api.steampowered.com/IEconService/GetTradeOffer/v1/?key=48B9FCE3FE8A74ADDA29174BFD47441B&amp;tradeofferid=530796219&amp;language=en_us</a>):</p>
  
  <pre><code>{
  "response": {
      "offer": {
          "tradeofferid": "530796219",
          "accountid_other": 213128749,
          "message": "Security Code: HqaMyUDN",
          "expiration_time": 1435675048,
          "trade_offer_state": 2,
          "items_to_receive": [
              {
                  "appid": "730",
                  "contextid": "2",
                  "assetid": "2275856684",
                  "classid": "310776767",
                  "instanceid": "0",
                  "amount": "1",
                  "missing": false
              }
          ]
          ,
          "is_our_offer": false,
          "time_created": 1434465448,
          "time_updated": 1434465448,
          "from_real_time_trade": false
      },...
  </code></pre>
  
  <p>Any ideas why one response is empty, but other is normal?</p>