简体   繁体   中英

SharePoint 2013 REST API - Post SocialRestPostCreationData

I'm currently working on a small application to push Post to a SharePoint 2013 SiteFeed using the Social.Feed API.

Basic Posts using the following JSON Object structure are working fine but I'm struggling using a Social-Attachment.

As long I'm referencing to the files located somewhere in the internet everything works. Posts will create listitems in micro-feed list with HTTP-Reference to the Files. The Object I'm using is set up like this

    var creationInfo = new
    {
        restCreationData = new
        {
            __metadata = new { type = "SP.Social.SocialRestPostCreationData" },
            ID = array,
            creationData = new
            {
                __metadata = new { type = "SP.Social.SocialPostCreationData" },

                Attachment = new
                {
                    __metadata = new { type = "SP.Social.SocialAttachment" },
                    AttachmentKind = 0,
                    ContentUri = "https://www.google.com/images/icons/hpcg/ribbon-black_68.png",
                    Description = "Look at this",
                    Name = "Test",
                    Uri = "https://www.google.com/images/icons/hpcg/ribbon-black_68.png"
                },
                ContentText = text,
                UpdateStatusText = false,
            }
        }
    };

Is there a possibility to use a local file instead? - Removing the google paths and using a local path in ContentUri will end up in a BAD-Request error.

I guess that the files has to be uploaded somehow before.

Thanks for you help.

Iki

After some trying we now ended up with the following solution.

  • Before we create the SocialPost, we upload the picture into an image gallery where all Feed users have access to.

  • Then we create the post containing a link to the image

-> This will do the trick.

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