ciaranmccormick / hootsweet

A Python API for Hootsuite
2 stars 0 forks source link

delete_message API throws an error. #11

Closed gghildyal closed 4 years ago

gghildyal commented 4 years ago

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)
ciaranmccormick commented 4 years ago

@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 commented 4 years ago

Fixed in the 0.5.1 release

gghildyal commented 4 years ago

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