使用OneDrive API将文件复制到OneDrive上的源文件夹

时间:2017-08-09 19:26:55

标签: onedrive

我尝试在OneDrive上复制文件:

  1. 请求:

    POST https://api.onedrive.com/v1.0/drive/root:/onedrive_test/foo/bar/a.txt:/action.copy
    Accept-Encoding: gzip, deflate
    Connection: keep-alive
    Content-Type: application/json
    Content-Length: 84
    Accept: */*
    Authorization: Bearer Ew...
    Prefer: respond-async
    User-Agent: python-requests/2.7.0 CPython/3.4.4 Windows/7
    
    b'{"parentReference": {"path": "/drive/root:/onedrive_test/foo/bar"}, "name": "b.txt"}'
    
  2. 回复:202接受

  3. 请求:

    GET https://api.onedrive.com/v1.0/monitor/4sT2gLAWdXVK7EdkDM7k24ObcUFTzScBof3T80HbmKfVHPnUCDK4fWe01ttH9...
    Accept-Encoding: gzip, deflate
    Connection: keep-alive
    Accept: */*
    Authorization: Bearer Ew...
    User-Agent: python-requests/2.7.0 CPython/3.4.4 Windows/7
    
    None
    
  4. 响应:如果复制到源文件所在的同一文件夹,则会出现500内部服务器错误。

  5. 如果我使用

    b'{"parentReference": {"path": "/drive/root:/onedrive_test/foo/bar2"}, "name": "b.txt"}'
    

    b'{"parentReference": {"path": "/drive/root:/onedrive_test/foo"}, "name": "b.txt"}'
    

    一切正常。

1 个答案:

答案 0 :(得分:0)

这是OneDrive Consumer的一个持续问题 - 一旦解决,我会回复此答案。