Search code examples
c#apirestsharptrellomanatee.trello

Getting MissingMethodException when using Manatee.trello to get list of users


I have the following code which is intended to fetch a list of all the user of an organisation.

public static IEnumerable<Member> ListTrelloUsers()
    {
        var serializer = new ManateeSerializer();
        TrelloConfiguration.Serializer = serializer;
        TrelloConfiguration.Deserializer = serializer;
        TrelloConfiguration.JsonFactory = new ManateeFactory();
        TrelloConfiguration.RestClientProvider = new RestSharpClientProvider();
        TrelloAuthorization.Default.AppKey = ApplicationKey;
        TrelloAuthorization.Default.UserToken = GrandToken;

        var myOrganization = Member.Me.Organizations.FirstOrDefault().Id; //Exception thrown here.
        var orgToAddTo = new Organization(myOrganization);

        return orgToAddTo.Members.AsEnumerable();
    }

But I'm getting a

System.MissingMethodException

thrown on

RestSharp.IRestRequest RestSharp.RestRequest.AddFile(System.String, Byte[], System.String)

So why is this exception thrown and what should the correctly working code look like?

Clarifications

I will also accept working C#/ASP.Net MVC code that isn't based on Manatee.Trello as an answer. (Including pure API-calls.)

I have tried using the Organisation ID directly as

var orgToAddTo = new Organization(OrganisationId);

but that just caused the same exception to be thrown later when I make a call to the method's returned object (e.g. using Count()).

UPDATE: I tried setting the build to Release instead of Debug and now the (same) exception is instead thrown at

TrelloConfiguration.RestClientProvider = new RestSharpClientProvider();

Solution

  • This is an issue with RestSharp that I reported quite some time ago, though they deny that it's a problem. If you're using .Net 4.5+, you can try the Manatee.Trello.WebApi package instead of Manatee.Trello.RestSharp.

    TrelloConfiguration.RestProvider = new WebApiClientProvider();
    

    Here's my Trello card for tracking the issue. This and this are the RestSharp issues I created.

    I have been able to recreate this as well, but have received no help from them to resolve it.