OneDrive / onedrive-sdk-python

OneDrive SDK for Python! https://dev.onedrive.com
MIT License
1.08k stars 189 forks source link

How to access special folders? #159

Open olav-st opened 5 years ago

olav-st commented 5 years ago

Hi, I'm trying to access my app folder (using the permission onedrive.appfolder). According to the documentation, this is a special folder. How can I access such folders using the Python SDK? I have tried calling:

client.drive.special.get()

But it throws an exception:

Traceback (most recent call last):
  File "unodrive.py", line 24, in <module>
    client.drive.special.get()
  File "/usr/local/lib/python3.6/dist-packages/onedrivesdk/request/special_collection.py", line 118, in get
    return self.request().get()
  File "/usr/local/lib/python3.6/dist-packages/onedrivesdk/request/special_collection.py", line 39, in get
    return self._page_from_response(collection_response)
  File "/usr/local/lib/python3.6/dist-packages/onedrivesdk/collection_base.py", line 47, in _page_from_response
    return response.collection_page
  File "/usr/local/lib/python3.6/dist-packages/onedrivesdk/request/special_collection.py", line 145, in collection_page
    self._collection_page = SpecialCollectionPage(self._prop_dict["value"])
KeyError: 'value'

To debug this issue I modified http_provider.py to print HTTP requests and reponses and got the following output:

https://api.onedrive.com/v1.0/drive/special
{"message":"No HTTP resource was found that matches the request URI 'https://api.onedrive.com/v1.0/drives('me')/special'."}

I'm not sure what's wrong here. Any ideas or suggestions?

olav-st commented 5 years ago

I ended up sending the request manually as a workaround:

import requests, json
endpoint = "https://api.onedrive.com/v1.0/drives/me/special/approot"
headers = {"Authorization": "Bearer " + access_token}
response = requests.get(endpoint, headers=headers).json()
appfolder_id = response["id"]
KTibow commented 4 years ago

@olav-st what do you get if you do client.drives.get() instead of drive.get()? I only get one drive, personal, but try exploring with autocomplete.