简体   繁体   中英

Get Data from SharePoint On Premise by using Syndication

I had a question about how can we get the data from SharePoint on premise list and implement in Bot?

Any sample for this?

and I'm using C# to develop ChatBot.

Here with the error for the ChatBot The element with name 'html' and namespace '' is not an allowed feed format.

在此处输入图像描述

and here with my source code

  try
                {
XmlReaderSettings settings = new XmlReaderSettings();
            settings.DtdProcessing = DtdProcessing.Parse;
           settings.ValidationType = ValidationType.DTD;
          settings.MaxCharactersFromEntities = 1024;

            XmlUrlResolver resolver = new XmlUrlResolver();
            resolver.Credentials = new NetworkCredential("username", "Pa$$w0rd", "mvponduty.com");

            settings.XmlResolver = resolver;
                    string spurl = "https://mvponduty.sharepoint.com/sites/sg/daw/_layouts/15/srchrss.aspx?k=*%20ListId:7BC0F2C3-6366-48B8-B88A-8738BE1F9C31";
                    XmlReader reader = XmlReader.Create(spurl,settings);
                    SyndicationFeed feed = SyndicationFeed.Load(reader);

                    reader.Close();

                    var attachments = new List<Attachment>();
                    foreach (SyndicationItem item in feed.Items)
                    {
                        //Get Title,Description,URL
                        String title = item.Title.Text;
                        String description = item.Summary.Text;
                        String link = item.Links.FirstOrDefault().Uri.ToString();

                        //Hero Card
                        var heroCard = new HeroCard(
                            title: item.Title.Text,
                            subtitle: description,
                            buttons: new CardAction[]
                            {
                            new CardAction(ActionTypes.OpenUrl,"LINK",value:link)
                            }
                            ).ToAttachment();
                        attachments.Add(heroCard);

                    }
                    var reply = MessageFactory.Carousel(attachments);
                    await turnContext.SendActivityAsync(reply);
                }
                catch (Exception ex)
                {
                    await turnContext.SendActivityAsync(ex.Message.ToString());
                }

Thank you.

Using SharePoint search API we can get data from SharePoint for the given input in bot. Bot framework solution will be created in .net core. so make sure your SharePoint calls are working fine.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM