0

I am using TweetSharp in a Windows Phone project and no matter what I do, I can't post a tweet with media.

I am getting the exception 195: Missing or invalid parameter.

I read that usually this can be a cause of invalid data, like the stream that I provide is invalid.

I have tried other way but nothing works , I get the same exception ...

The sharing code, simplified is like this:

MediaLibrary library = new MediaLibrary();

        var picture = library.Pictures[0];

        var options = new SendTweetWithMediaOptions
            {
                Images = new Dictionary<string, Stream> { { picture.Name, picture.GetImage() } },
                Status = TweetTextBox.Text,
            };


        AutentificateTwitterService().SendTweetWithMedia(options, (status, response) =>
                                    _dispatcher.BeginInvoke(() =>
                                        {
                                            DonePosting();

                                            if (response.StatusCode == HttpStatusCode.OK)
                                            {
                                                _lastPostId = status.Id;
                                            }
                                            else
                                            {
                                                MessageBox.Show(String.Format(
                                                        "There was an error sending image to Twitter{0}{1}",
                                                        Environment.NewLine,
                                                        response.Error));
                                            }
                                       })); 

I tried sharing with linqtotwitter and worked but TweetSharp is more appropriate for my project.

1 Answers1

2

Finally after some time I've found the problem to this and I am sure to other more WP and SendTweetWithMediaOptions related problems.

The thing is that if you dig into SendTweetWithMedia the way it is now you will get to TwitterService.cs where WithHammock will be called, is just the images are not passed as parrameters, so they get lost right there :)

I did fix this passing the parameters and adding

private void WithHammock<T>(WebMethod method, Action<T, TwitterResponse> action, string path, IDictionary<string, Stream> files, params object[] segments) where T : class
    {
        var url = ResolveUrlSegments(path, segments.ToList());
        var request = PrepareHammockQuery(url);
        request.Method = method;
        request.QueryHandling = QueryHandling.AppendToParameters;
        foreach (var file in files)
        {
            request.AddFile("media[]", file.Key, file.Value);
        }
        WithHammockImpl(request, action);
    }

I will try and see if I can Pull this so that everyone else can have this fix.

Hope this helps.