Trello C# api, .Boards.WithId() and .Members.Me() are always null

对着背影说爱祢 提交于 2019-12-12 21:12:44

问题


I'm getting started with C# Trello API. I'we created simple console application, and ran it first to get access token:

static void GetToken()
{
     ITrello trello = new Trello("application key");
     var url = trello.GetAuthorizationUrl("Test api", Scope.ReadWrite, Expiration.Never);
     Process.Start(url.ToString());
}

Process.Start opened my default browser instance, I allowed access for the application and on the next page got my token. Then I hardcoded the token and tried to implement this example:

static void Main(string[] args)
{
     ITrello trello = new Trello("application key");
     trello.Authorize(token); // hardcoded token

     Member me = trello.Members.Me();
     Console.WriteLine(me.FullName);
}

But me is always null. What am I missing? Is authorization failed? If so, why don't I get TrelloNet.TrelloUnauthorizedException?

EDITS: After a while I'we found some suggestion about Json.NET version included in the project in this thread so I updated Json.NET and now I get TrelloNet.TrelloException with no message in line:

Member me = trello.Members.Me();

StackTrace:

at TrelloNet.Internal.TrelloRestClient.ThrowIfRequestWasUnsuccessful(IRestRequest request, IRestResponse response)
   at TrelloNet.Internal.TrelloRestClient.Request[T](IRestRequest request)
   at TrelloNet.Internal.Members.Me()
   at ConsoleApplication1.Program.Main(String[] args) in f:\Dropbox\Projects\TrelloManager\ConsoleApplication1\Program.cs:line 26
   at System.AppDomain._nExecuteAssembly(RuntimeAssembly assembly, String[] args)
   at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
   at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
   at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
   at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
   at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
   at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
   at System.Threading.ThreadHelper.ThreadStart()

回答1:


This might help. I had the same problem of everything coming back null. I found that getting latest versions of certain components solved the problem.

See this article: Trello.Net authorisation works but cannot access data once authorised



来源:https://stackoverflow.com/questions/29967865/trello-c-sharp-api-boards-withid-and-members-me-are-always-null

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!