sharepoint-2013sharepoint-onlineoffice365-restapi

How to save a list item into specific folder in SharePoint list using REST API?


I have to save items into SharePoint list where I have specific folders in it and I have to save the item into that particular folder based on the item. I've retrieved the items from specific folders but how to save a list item into specific folder in SharePoint list using REST API?


Solution

  • use listdata.svc

    var metadata={Title: "Title", Path: "/ServerRelativeUrl of your folder in the list"};
    $.ajax({
                    url: url + "/_vti_bin/ListData.svc/[List Name]",
                    type: "POST",
                    contentType: "application/json;odata=verbose",
                    data: JSON.stringify(metadata),
                    headers: {
                        "Accept": "application/json;odata=verbose",
                        "X-RequestDigest": $("#__REQUESTDIGEST").val()
                    },
                    success: function (data) {
                        self.options.success(data);
                    },
                    error: function (data) {
                        self.options.error(data);
                    }
                });