【问题标题】:Trello Manatee adding attachmentTrello Manatee 添加附件
【发布时间】:2015-07-23 22:26:15
【问题描述】:

我正在尝试使用 Manatee API 向预先创建的 Trello 卡添加附件。

这就是我创建卡片的方式,我对它没有任何问题:

        /// <summary>
        ///  This function creates a card on Trello <Board_Name> board, into the list named <List_Name>.
        ///  It creates a card with the title and descrition comming from the function which is called
        /// </summary>
        /// <param name="subject"> This is the subject (Title) of the ticket </param>
        /// <param name="body"> This is the body section (description) of the ticket </param>
        public string createTrelloTicketCard(string subject, string body)
        {
            string cardId = null;
            trelloToken = adminTrelloToken; // define who is creating the card

            Run(() =>
            {
                TrelloProcessor.WaitForPendingRequests = true;
                var board = new Board(<Board_ID>); // board id
                var list = board.Lists[5]; // The sixth list of the board 

                var card = list.Cards.Add(subject); // create a card with the subject from tblTasks
                cardId = card.Id; // get the created card ID
                card.Description = body; // define description from tblTasks
                
                // Add all the IT members to the card
                for (int i = 0; i < numberOfItMembersInBoard; i ++)
                {
                    card.Members.Add(board.Members[i]); 
                }
            });

            return cardId;
        }

这就是我尝试向卡片添加附件的方式。该函数出现问题:

public void InsertAttachementIntoTrelloCard(string cardId, byte[] buffer, string name)
        {
            Run(() =>
            {
                TrelloProcessor.WaitForPendingRequests = true;

                var board = new Board(<Board_ID>); // board id
                
                var list = board.Lists[5]; // The sixth list of the board 
                
                var card = new Card(cardId); // specify the card that the file is going to be attached
                card.Description = "Test3";

                card.Attachments.Add(buffer, name); // Here I get the error
            });
        }

当我尝试附加文件时,我收到以这句话开头的错误:

对象引用未设置为对象的实例。

我很确定创建的字节数组是正确的,当我删除该行时,程序结束时没有任何错误。我是不是用错了方法?

这是堆栈跟踪:

ex.Message = "对象引用未设置为对象的实例。"

ex.StackTrace = " 在 海牛.Trello.Internal.DataAccess.JsonRepository.PrepRequest(IRestRequest 请求,TrelloAuthorization auth) 在 e:\Projects\Manatee.Trello\Manatee.Trello\Internal\DataAccess\JsonRepository.cs:line 79 在 Manatee.Trello.Internal.DataAccess.JsonRepository.BuildRequest(TrelloAuthorization auth,Endpoint 端点,IDictionary`2 参数)在 e:\Projects\Manatee.Trello\Manatee.Trello\Internal\DataAccess\JsonRepository.cs:line 74 在 Manatee.Trello.Internal.DataAccess.JsonRepository.Execute[T](TrelloAuthorization auth,Endpoint 端点,IDictionary'2 参数)在 e:\Projects\Manatee.Trello\Manatee.Trello\Internal\DataAccess\JsonRepository.cs:line 46 在 Manatee.Trello.AttachmentCollection.Add(Byte[] 数据,字符串 名称)在 e:\Projects\Manatee.Trello\Manatee.Trello\AttachmentCollection.cs:line 112 在 Live.XmlFax.XmlFaxForm.c__DisplayClass8.b__7() 在 c:\Users\arif.gencosmanoglu\Documents\EnteringC#\Printer Project\XmlFax\XmlFaxForm.cs:第 2035 行,位于 Live.XmlFax.XmlFaxForm.Run(Action action) 在 c:\Users\arif.gencosmanoglu\Documents\EnteringC#\Printer 项目\XmlFax\XmlFaxForm.cs:第 1724 行 Live.XmlFax.XmlFaxForm.InsertAttachementIntoTrelloCard(字符串 cardId, Byte[] 缓冲区,字符串名称)在 c:\Users\arif.gencosmanoglu\Documents\EnteringC#\Printer Project\XmlFax\XmlFaxForm.cs:第 2023 行,位于 Live.XmlFax.XmlFaxForm.ReadTicketEmail() 在 c:\Users\arif.gencosmanoglu\Documents\EnteringC#\Printer Project\XmlFax\XmlFaxForm.cs: 1981 行,位于 Live.XmlFax.XmlFaxForm.cmdItTicket_Click(对象发送者,EventArgs e) 在 c:\Users\arif.gencosmanoglu\Documents\EnteringC#\Printer 项目\XmlFax\XmlFaxForm.cs:1884 行

【问题讨论】:

  • @GrantWinney 是的,我首先创建了一张没有附件的卡片,然后我使用创建的卡片 ID 调用我的函数来添加附件。
  • 我是 Manatee.Trello 的创造者。你能更新堆栈跟踪吗?您可能发现了一个隐藏的错误。我看不出你做错了什么。这通常对我有用(在我的盒子上工作!哈哈)
  • @GrantWinney, Attachments 永远不会为空。该集合是在卡片构造时创建的。
  • @0014,请升级后重试。
  • 请同时升级 Manatee.Trello.ManateeJson 和 Manatee.Trello.RestSharp

标签: c# attachment trello manatee.trello


【解决方案1】:

我不知道问题出在哪里。堆栈跟踪中到该点的每条路径都涵盖了所有依赖项,因此不应发生该错误。

请确保您拥有以下最新的 Nuget 包:

  • 海牛.Trello
  • Manatee.Trello.ManateeJson
  • Manatee.Trello.RestSharp

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-05-14
    • 1970-01-01
    • 2021-12-14
    • 2018-10-08
    • 1970-01-01
    • 2017-04-28
    相关资源
    最近更新 更多