insert page attachment using rest api in kentico 13 from non kentico project

ravi yadav asked on January 9, 2023 06:51

hello concern,

i want to add kentico page attachment using field guid in kentico 13 but i am using another project for it can you help me with rest api to insert page attachement. below code i used in same project but i have to do it with rest api



HttpFileCollection oHttpFileCollection = files; HttpPostedFile oHttpPostedFile = oHttpFileCollection[0]; string fileFileName = oHttpFileCollection[0].FileName; if (spage != null) {

 DocumentAttachment attachment = new DocumentAttachment();
 Guid attachmentGuid = Guid.NewGuid();
 // Adds the file as an attachment of the page  e9193c3a - f32a - 447c - 905e-ef8e8e603dfe
 // attachment = DocumentHelper.AddUnsortedAttachment(spage, attachmentGuid, oHttpPostedFile);
 Guid fieldGuid = Guid.Parse("e9193c3a-f32a-447c-905e-ef8e8e603dfe");
 attachment = DocumentHelper.AddGroupedAttachment(spage,attachmentGuid,fieldGuid,oHttpPostedFile);
 spage.Update();
 spage.MoveToPublishedStep();
 spage.ClearCache();
 spage.CreateNewVersion();
 spage.MoveToPublishedStep();

}

Recent Answers


Brenden Kehren answered on January 9, 2023 14:43

Have you checked out the API examples for Attachments?

0 votesVote for this answer Mark as a Correct answer

ravi yadav answered on January 10, 2023 05:51

yes, but i want to use rest api

0 votesVote for this answer Mark as a Correct answer

Brenden Kehren answered on January 10, 2023 13:28

I didn't see that before. I don't believe Attachments are supposed by the REST API. You might want to read up on the documentation.

0 votesVote for this answer Mark as a Correct answer

   Please, sign in to be able to submit a new answer.