Working with List items by using Rest API`s for SharePoint 2013 RRS feed

  • Question

  • hello, does any one try to use the Rest API`s in SharePoint 2013 to create a task and add an attachment to it, and any one try to copy list item from one list to another using rest API`s too
    Monday, December 9, 2013 7:54 AM


  • The following link shows you how to add an attachment to a list item. A task is basically a list item.


    You can only copy a list item to another list if it is in a document library. This is because you can only use the SPFile object and the CopyTo method. This can be done using REST.

    function copyFile() {
        hostweburl = decodeURIComponent(getQueryStringParameter('SPHostUrl'));
        appweburl = decodeURIComponent(getQueryStringParameter('SPAppWebUrl'));
        destUrl = appweburl + "/_api/SP.AppContextSite(@target)/web/folders/GetByUrl('shared documents')/Files/getbyurl('A1210251607125103221.pdf')/copyTo(strNewUrl = 'Duplicates/A1210251607125103221.pdf',bOverWrite = true)?@target='" + hostweburl + "'";
            url: destUrl,
            method: 'POST',
            headers: {
                "Accept": "application/json; odata=verbose",
                "X-RequestDigest": $("#__REQUESTDIGEST").val()
            success: function () {
                alert("Success! Your file was copied properly");
            error: function () {
                alert("Problem with copying");

    Blog |<a href="http://www.sharepointfieldnotes.blogspot.com">SharePoint Field Notes</a> Dev Tools | <a href="http://visualstudiogallery.msdn.microsoft.com/9e03d0f5-f931-4125-a5d1-7c1529554fbd"> SPFastDeploy</a><[a href="http://bit.ly/1cpgILA">SPRemoteAPIExplorer

    • Proposed as answer by SekThang Sunday, January 5, 2014 7:21 AM
    • Marked as answer by Trevor SewardMVP Friday, January 31, 2014 5:55 AM
    Sunday, January 5, 2014 5:30 AM