WebexCommunity / WebexPythonSDK

Work with the Webex APIs in native Python!
https://webexcommunity.github.io/WebexPythonSDK/
MIT License
239 stars 153 forks source link

Issue Retrieving Messages from a room. #196

Open rishibhatia5354 opened 1 year ago

rishibhatia5354 commented 1 year ago

Below is my sample code.

from webexteamssdk import WebexTeamsAPI from itertools import islice

api = WebexTeamsAPI(access_token=os.environ['WEBEX_ACCESS_TOKEN']) messages = api.messages.list(roomId='XXXXXXX')

for message in islice(messages, 50): print(message)

for message in messages: print(message)

Both the print statements, give me the below error.

test.py Traceback (most recent call last): File "test.py", line 15, in for message in islice(messages, 50): File "/opt/homebrew/lib/python3.11/site-packages/webexteamssdk/api/messages.py", line 138, in list for item in items: File "/opt/homebrew/lib/python3.11/site-packages/webexteamssdk/restsession.py", line 464, in get_items for json_page in pages: File "/opt/homebrew/lib/python3.11/site-packages/webexteamssdk/restsession.py", line 419, in get_pages response = self.request("GET", url, erc, params=params, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/opt/homebrew/lib/python3.11/site-packages/webexteamssdk/restsession.py", line 357, in request check_response_code(response, erc) File "/opt/homebrew/lib/python3.11/site-packages/webexteamssdk/utils.py", line 222, in check_response_code raise ApiError(response) webexteamssdk.exceptions.ApiError: [403] Forbidden - Failed to get activity. [Tracking ID: ROUTER_64DCDB0XXXXXXXXX]

This is running fine when I use Postman/ https://developer.webex.com/docs/api/v1/messages/list-messages

Screenshot 2023-08-16 at 20 00 32
ashok-an commented 1 year ago

+1 Same issue with webexteamssdk==1.6.0 as well

rishibhatia5354 commented 1 year ago

Attaching the error trace log generated from the logging module as well.

2023-08-17 09:36:25.2525 - ERROR - Error Traceback (most recent call last):

File "***/test.py", line 19, in for message in islice(messages, 50): │ └ <GeneratorContainer list(self=<webexteamssdk.api.messages.MessagesAPI object at 0x147bfd790>, roomId='91e612a0-**... └ <class 'itertools.islice'>

File "/opt/homebrew/lib/python3.11/site-packages/webexteamssdk/api/messages.py", line 138, in list for item in items: └ <generator object RestSession.get_items at 0x147bd05e0> File "/opt/homebrew/lib/python3.11/site-packages/webexteamssdk/restsession.py", line 464, in get_items for json_page in pages: └ <generator object RestSession.get_pages at 0x147c008c0> File "/opt/homebrew/lib/python3.11/site-packages/webexteamssdk/restsession.py", line 419, in get_pages response = self.request("GET", url, erc, params=params, **kwargs) │ │ │ │ │ └ {} │ │ │ │ └ {'roomId': '91e612a0-*****', 'max': 50} │ │ │ └ 200 │ │ └ 'messages' │ └ <function RestSession.request at 0x147b8f920> └ <webexteamssdk.restsession.RestSession object at 0x105147c90> File "/opt/homebrew/lib/python3.11/site-packages/webexteamssdk/restsession.py", line 357, in request check_response_code(response, erc) │ │ └ 200 │ └ <Response [403]> └ <function check_response_code at 0x147b671a0> File "/opt/homebrew/lib/python3.11/site-packages/webexteamssdk/utils.py", line 222, in check_response_code raise ApiError(response) │ └ <Response [403]> └ <class 'webexteamssdk.exceptions.ApiError'>

webexteamssdk.exceptions.ApiError: [403] Forbidden - Failed to get activity. [Tracking ID: ROUTER_64DD9CB4**] 2023-08-17 09:36:25.2525 - ERROR - Errors Traceback (most recent call last):

File "**/test.py", line 24, in for message in messages: └ <GeneratorContainer list(self=<webexteamssdk.api.messages.MessagesAPI object at 0x147bfd790>, roomId='91e612a0-**...

File "/opt/homebrew/lib/python3.11/site-packages/webexteamssdk/api/messages.py", line 138, in list for item in items: └ <generator object RestSession.get_items at 0x147bd05e0> File "/opt/homebrew/lib/python3.11/site-packages/webexteamssdk/restsession.py", line 464, in get_items for json_page in pages: └ <generator object RestSession.get_pages at 0x147c008c0> File "/opt/homebrew/lib/python3.11/site-packages/webexteamssdk/restsession.py", line 419, in get_pages response = self.request("GET", url, erc, params=params, kwargs) │ │ │ │ │ └ {} │ │ │ │ └ {'roomId': '91e612a0**', 'max': 50} │ │ │ └ 200 │ │ └ 'messages' │ └ <function RestSession.request at 0x147b8f920> └ <webexteamssdk.restsession.RestSession object at 0x105147c90> File "/opt/homebrew/lib/python3.11/site-packages/webexteamssdk/restsession.py", line 357, in request check_response_code(response, erc) │ │ └ 200 │ └ <Response [403]> └ <function check_response_code at 0x147b671a0> File "/opt/homebrew/lib/python3.11/site-packages/webexteamssdk/utils.py", line 222, in check_response_code raise ApiError(response) │ └ <Response [403]> └ <class 'webexteamssdk.exceptions.ApiError'>

webexteamssdk.exceptions.ApiError: [403] Forbidden - Failed to get activity. [Tracking ID: ROUTER_64DD9CB4****]

Joezanini commented 2 months ago

Hello Devs, could you try this with the new SDK and report if the error still exists?