我正在尝试使用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 =&#34;对象引用未设置为对象的实例。&#34;
ex.StackTrace =&#34;在 Manatee.Trello.Internal.DataAccess.JsonRepository.PrepRequest(IRestRequest 请求,TrelloAuthorization auth)in E:\项目\ Manatee.Trello \ Manatee.Trello \内部\的DataAccess \ JsonRepository.cs:行 79点 Manatee.Trello.Internal.DataAccess.JsonRepository.BuildRequest(TrelloAuthorization auth,Endpoint endpoint,IDictionary`2 parameters)in E:\项目\ Manatee.Trello \ Manatee.Trello \内部\的DataAccess \ JsonRepository.cs:行 74点 Manatee.Trello.Internal.DataAccess.JsonRepository.Execute [T](TrelloAuthorization auth,Endpoint endpoint,IDictionary&#39; 2参数)in E:\项目\ Manatee.Trello \ Manatee.Trello \内部\的DataAccess \ JsonRepository.cs:行 46 at Manatee.Trello.AttachmentCollection.Add(Byte [] data,String 姓名)in E:\项目\ Manatee.Trello \ Manatee.Trello \ AttachmentCollection.cs:行 112点 Live.XmlFax.XmlFaxForm&LT;&GT; c__DisplayClass8.b__7() 在c:\ Users \ arif.gencosmanoglu \ Documents \ EnteringC#\ Printer中 Project \ XmlFax \ XmlFaxForm.cs:第2035行 Live.XmlFax.XmlFaxForm.Run(Action action)in C:\用户\ arif.gencosmanoglu \文档\ EnteringC#\打印机 Project \ XmlFax \ XmlFaxForm.cs:第1724行 Live.XmlFax.XmlFaxForm.InsertAttachementIntoTrelloCard(String cardId, 字节[]缓冲区,字符串名称)中 C:\用户\ arif.gencosmanoglu \文档\ EnteringC#\打印机 Project \ XmlFax \ XmlFaxForm.cs:第2023行 Live.XmlFax.XmlFaxForm.ReadTicketEmail()in C:\用户\ arif.gencosmanoglu \文档\ EnteringC#\打印机 Project \ XmlFax \ XmlFaxForm.cs:1981年的第一行 Live.XmlFax.XmlFaxForm.cmdItTicket_Click(Object sender,EventArgs e) 在c:\ Users \ arif.gencosmanoglu \ Documents \ EnteringC#\ Printer中 Project \ XmlFax \ XmlFaxForm.cs:第1884行
答案 0 :(得分:1)
我不知道问题出在哪里。堆栈跟踪中到达该点的每条路径都包含所有依赖关系,并且该错误不应该发生。
请确保您拥有以下最新的Nuget套餐: