@@ -48,6 +48,7 @@ def __init__(
4848
4949 self .base_url = self .RESOURCE + self .api_version + "/"
5050 self .token = None
51+ self .workbook_session_id = None
5152 self .paginate = paginate
5253
5354 self .calendar = Calendar (self )
@@ -166,6 +167,14 @@ def set_token(self, token: dict) -> None:
166167 """
167168 self .token = token
168169
170+ def set_workbook_session_id (self , workbook_session_id : dict ) -> None :
171+ """Sets the Workbook Session Id token for its use in this library.
172+
173+ Args:
174+ token (dict): Workbook Session ID.
175+ """
176+ self .workbook_session_id = workbook_session_id
177+
169178 def _paginate_response (self , response : dict , ** kwargs ) -> dict :
170179 """Some queries against Microsoft Graph return multiple pages of data either due to server-side paging or due to
171180 the use of the $top query parameter to specifically limit the page size in a request. When a result set spans
@@ -180,7 +189,7 @@ def _paginate_response(self, response: dict, **kwargs) -> dict:
180189 Returns:
181190 dict: Graph API Response.
182191 """
183- if not self .paginate :
192+ if not self .paginate or not isinstance ( response . data , dict ) :
184193 return response
185194 while "@odata.nextLink" in response .data :
186195 data = response .data ["value" ]
@@ -224,51 +233,51 @@ def _parse(self, response):
224233 if status_code in (200 , 201 , 202 , 204 , 206 ):
225234 return r
226235 elif status_code == 400 :
227- raise exceptions .BadRequest (r )
236+ raise exceptions .BadRequest (r . data )
228237 elif status_code == 401 :
229- raise exceptions .Unauthorized (r )
238+ raise exceptions .Unauthorized (r . data )
230239 elif status_code == 403 :
231- raise exceptions .Forbidden (r )
240+ raise exceptions .Forbidden (r . data )
232241 elif status_code == 404 :
233- raise exceptions .NotFound (r )
242+ raise exceptions .NotFound (r . data )
234243 elif status_code == 405 :
235- raise exceptions .MethodNotAllowed (r )
244+ raise exceptions .MethodNotAllowed (r . data )
236245 elif status_code == 406 :
237- raise exceptions .NotAcceptable (r )
246+ raise exceptions .NotAcceptable (r . data )
238247 elif status_code == 409 :
239- raise exceptions .Conflict (r )
248+ raise exceptions .Conflict (r . data )
240249 elif status_code == 410 :
241- raise exceptions .Gone (r )
250+ raise exceptions .Gone (r . data )
242251 elif status_code == 411 :
243- raise exceptions .LengthRequired (r )
252+ raise exceptions .LengthRequired (r . data )
244253 elif status_code == 412 :
245- raise exceptions .PreconditionFailed (r )
254+ raise exceptions .PreconditionFailed (r . data )
246255 elif status_code == 413 :
247- raise exceptions .RequestEntityTooLarge (r )
256+ raise exceptions .RequestEntityTooLarge (r . data )
248257 elif status_code == 415 :
249- raise exceptions .UnsupportedMediaType (r )
258+ raise exceptions .UnsupportedMediaType (r . data )
250259 elif status_code == 416 :
251- raise exceptions .RequestedRangeNotSatisfiable (r )
260+ raise exceptions .RequestedRangeNotSatisfiable (r . data )
252261 elif status_code == 422 :
253- raise exceptions .UnprocessableEntity (r )
262+ raise exceptions .UnprocessableEntity (r . data )
254263 elif status_code == 429 :
255- raise exceptions .TooManyRequests (r )
264+ raise exceptions .TooManyRequests (r . data )
256265 elif status_code == 500 :
257- raise exceptions .InternalServerError (r )
266+ raise exceptions .InternalServerError (r . data )
258267 elif status_code == 501 :
259- raise exceptions .NotImplemented (r )
268+ raise exceptions .NotImplemented (r . data )
260269 elif status_code == 503 :
261- raise exceptions .ServiceUnavailable (r )
270+ raise exceptions .ServiceUnavailable (r . data )
262271 elif status_code == 504 :
263- raise exceptions .GatewayTimeout (r )
272+ raise exceptions .GatewayTimeout (r . data )
264273 elif status_code == 507 :
265- raise exceptions .InsufficientStorage (r )
274+ raise exceptions .InsufficientStorage (r . data )
266275 elif status_code == 509 :
267- raise exceptions .BandwidthLimitExceeded (r )
276+ raise exceptions .BandwidthLimitExceeded (r . data )
268277 else :
269278 if r ["error" ]["innerError" ]["code" ] == "lockMismatch" :
270279 # File is currently locked due to being open in the web browser
271280 # while attempting to reupload a new version to the drive.
272281 # Thus temporarily unavailable.
273- raise exceptions .ServiceUnavailable (r )
274- raise exceptions .UnknownError (r )
282+ raise exceptions .ServiceUnavailable (r . data )
283+ raise exceptions .UnknownError (r . data )
0 commit comments