-
Notifications
You must be signed in to change notification settings - Fork 152
Character encoding error - SparkApiError does not exist? #24
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
BTW, fantastic library !! Job well done. |
@DJF3 , hmm... This is an interesting one. I pretty regularly working with room names that have special characters (mostly emoticons in my case). Can you share the full 'Exception' output when you are seeing iteration stop at these items? You are handling errors correctly. Catching Check out: except SparkApiError as e:
pass
>>> e.request
>>> e.response
>>> # Especially:
>>> e.response.text |
Weather tried locally (macbook) or using a hosting provider:
There's no difference when using pass instead of print(e) Generates an error message: This should absolutely generate an error as both the access token and the room id are wrong. |
...you are correct. It definitely should (and is) generating an exception. To catch a custom / package exception, you have to import that exception into your namespace. You are just missing Your code should look like this: #!/Library/Frameworks/Python.framework/Versions/3.5/bin/python3
# coding=utf-8
import os
from ciscosparkapi import CiscoSparkAPI, SparkApiError
os.environ['SPARK_ACCESS_TOKEN'] = 'xyzxyz'
api = CiscoSparkAPI()
try:
message = api.messages.create('123098123098123098123098123', text='message_text')
print("New message created, with ID:", message.id)
print(message.text)
except SparkApiError as e:
print(e) Which runs and does indeed catch the exception(s) and print them when they are fired. |
Uh oh!
There was an error while loading. Please reload this page.
When listing all the rooms of a user it stops at
room name: "Domás"
When replacing all accents in the room.title it processes the above room but stops at:
room name: "Rob Ørnebånd"
So I tried to use the example from the Readme.md file, using the try-except:
Error message: "SparkApiError undefined" or something similar.
Question:
#1 .. How to deal with strange characters in room names?
(I just ran into room names starting with an emoticon)
#2 .. How to handle errors? (or see what happened when requesting a room list?)
Python: 3.5
Listing the rooms works perfectly when running the script from the command line instead of using CGI.
The text was updated successfully, but these errors were encountered: