title: How to copy file using Rest API and javascript in Sharepoint 2013 between site and subsite
body: <p>I need to copy file between document libraries. Library A is located in one site and Library B is located in subsite. I know how to copy file between libraries on the same level but the problem is with copying between different level.</p>
  
  <p>The code I use to copy file between libraries on the same level.</p>
  
  <pre><code> $.ajax({
       url : "http://xxx/PWA/_api/web/folders/GetByUrl('/PWA/CopyFromLibrary')/Files/getbyurl('Import.csv')/copyTo(strNewUrl = '/PWA/TargetLibrary/Import.csv',bOverWrite = true)",
  
  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");
      }
      });
  </code></pre>
  
  <p>For different level I use just another target URL:</p>
  
  <pre><code>url : "http://xxx/PWA/_api/web/folders/GetByUrl('/PWA/CopyFromLibrary')/Files/getbyurl('Import.csv')/copyTo(strNewUrl = '/PWA/Subsite/TargetLibrary/Import.csv',bOverWrite = true)",
  </code></pre>
  
  <p>And it doesn't work.
  How to work around this problem?</p>