NullReferenceException

Oct 11, 2013 at 8:23 AM
Hello,
It appears that _lastHeadersResult can be null in TwitterToken.Token.ExecuteQuery(string,HttpMethod,ObjectResponseDelegate,WebExceptionHandlingDelegate) line 201
This issue occurs randomly, after adding a _lastHeadersResult != null condition the problem does not occur again.
Coordinator
Oct 11, 2013 at 8:32 AM
Hi there,

Thank you for reporting the issue.
I will have a look later in the day and keep you up to date.

Regards,
Linvi
Coordinator
Oct 11, 2013 at 8:46 AM
Hi Math,

I see your point but would you please share with me the Twitter API calls you are performing.
So far I have never get this error and was assuming it seems quite unlikely that any Twitter Response would not have any header.

I am just curious about this Exception. If you could please share more information so I can understand what is happening.

Kind Regards,
Linvi
Oct 11, 2013 at 9:40 AM
Edited Oct 11, 2013 at 9:40 AM
I think i found what's the cause.
Try to share a same tweet multiple time until getting the specific error (case "403 Forbidden":
                        // You are trying to post the same Tweet another time!) 
(which is not throw from your API, is it the behavior you wanted ?), then stop the program or whatever to get a new fresh instance of the api, and send the same tweet again.
Hope this helps
Coordinator
Oct 11, 2013 at 9:58 AM
Hi Math,

By default Twitter does not permit a user to post the same tweet multiple times using the REST API.
I will check whether this exception should be swallowed or not.

In the meantime would you please send me a short version of your code so that I can reproduce it in your specific context?
You can send it to me by email if you do not want to share it on the discussion channel.

Contact Me By Mail

Thank you very much for the details.
Oct 14, 2013 at 9:17 AM
I'll do this today
Thanks
Oct 14, 2013 at 9:45 AM
In fact it is not necessary to send a project, you just need to create a C# console project :
    class Program
    {
        static void Main(string[] args)
        {
            string accountToken = "";
            string accountMetadata = "";
            string clientId = "";
            string clientSecret = "";

            TwitterToken.Token twitterToken = new TwitterToken.Token(accountToken, accountMetadata, clientId, clientSecret);
            TweetinCore.Interfaces.ITweet t = new Tweetinvi.Tweet("I like sushis");

            t.Publish(twitterToken);
            Console.WriteLine("Tweet");

            Console.ReadLine();
        }
    }
Then start it twice, second time you'll get the exception
Coordinator
Oct 14, 2013 at 11:45 AM
Thank you very much for the response.
I will check this and let you know what I've decided.
Coordinator
Oct 14, 2013 at 10:13 PM
Edited Oct 14, 2013 at 10:15 PM
Hi Math,

This behavior is expected. Tweet.Publish returns a boolean representing the success or failure of the publication.
The objective was to simplify the development so that developers do not have to do a try/catch every time they simply publish a Tweet.

Concerning the initial issue, I have added a _lastHeadersResult != null as you suggested.

Thanks for reporting this issue as well as the URL shortener :)

Linvi
Marked as answer by linvi on 10/29/2013 at 4:38 AM