1

I'm trying to access the list of attachments sent by the user to the skype bot that I'm developing.

Here is how I access the attachment details ,

     public async Task<HttpResponseMessage> Post([FromBody]Activity message)
     {

        if (message.Attachments != null)
        {
            if (message.Attachments.Count > 0)
            {
                List<Attachment> attachmentList = message.Attachments.ToList();

                foreach (var item in attachmentList)
                {
                    var name = item.Name;
                    var content = item.Content;
                }
            }
        }
     }

But I get null for the following even though the attachment count is greater than zero,

   var name = item.Name;
   var content = item.Content;

Am I doing this right?

1 Answers1

-2

Maybe do something like this...

List<Attachment> attachmentList = message?.Attachments?.Where(x => x != null)?.ToList() ?? new List<Attachment>();

This would hopefully always set attachmentList to an empty list or a list containing non null items?

BRBALS
  • 1
  • 3