Skip to content
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

delete_message API throws an error. #11

Closed
gghildyal opened this issue Apr 7, 2020 · 3 comments
Closed

delete_message API throws an error. #11

gghildyal opened this issue Apr 7, 2020 · 3 comments
Assignees

Comments

@gghildyal
Copy link
Collaborator

delete_message API doesn't return a 'data' attribute on success, hence the error.

"/Users/gghildyal/ito/projects/gitops/disruption_messaging/disruption_messaging/social/hootsuite.py", line 125, in schedule_message
    self.delete_message()
  File "/Users/gghildyal/ito/projects/gitops/disruption_messaging/disruption_messaging/social/hootsuite.py", line 144, in delete_message
    self.client.delete_message(self.message_id)
  File "/Users/gghildyal/ito/projects/gitops/disruption_messaging/venv/lib/python3.7/site-packages/hootsweet/api.py", line 243, in delete_message
    return self._make_request(resource, method="DELETE")
  File "/Users/gghildyal/ito/projects/gitops/disruption_messaging/venv/lib/python3.7/site-packages/hootsweet/api.py", line 107, in _make_request
    return response.json()["data"]
  File "/Users/gghildyal/ito/projects/gitops/disruption_messaging/venv/lib/python3.7/site-packages/requests/models.py", line 898, in json
    return complexjson.loads(self.text, **kwargs)
  File "/usr/local/opt/python/Frameworks/Python.framework/Versions/3.7/lib/python3.7/json/__init__.py", line 348, in loads
    return _default_decoder.decode(s)
  File "/usr/local/opt/python/Frameworks/Python.framework/Versions/3.7/lib/python3.7/json/decoder.py", line 337, in decode
    obj, end = self.raw_decode(s, idx=_w(s, 0).end())
  File "/usr/local/opt/python/Frameworks/Python.framework/Versions/3.7/lib/python3.7/json/decoder.py", line 355, in raw_decode
    raise JSONDecodeError("Expecting value", s, err.value) from None
json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)
@gghildyal gghildyal self-assigned this Apr 7, 2020
@ciaranmccormick
Copy link
Owner

@gghildyal That's really weird the documentation says that it returns a data object in the body if a 200 status code is returned https://platform.hootsuite.com/docs/api/index.html#operation/deleteMessage
I'll investigate and create a fix thanks.

ciaranmccormick added a commit that referenced this issue Apr 7, 2020
Hootsuite documentation states that if a delete operation is
successful that "data":{} is returned, however the api actually
returns "".
Added conditional to check method and return dict object if a
delete operation occurred.
@ciaranmccormick
Copy link
Owner

Fixed in the 0.5.1 release

@gghildyal
Copy link
Collaborator Author

@ciaranmccormick Many thanks for fixing this, definitely a bug in their API. I will raise one with them.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants