{"action":"opened","issue":{"url":"https://api.github.com/repos/calmh/unifi-api/issues/54","repository_url":"https://api.github.com/repos/calmh/unifi-api","labels_url":"https://api.github.com/repos/calmh/unifi-api/issues/54/labels{/name}","comments_url":"https://api.github.com/repos/calmh/unifi-api/issues/54/comments","events_url":"https://api.github.com/repos/calmh/unifi-api/issues/54/events","html_url":"https://github.com/calmh/unifi-api/issues/54","id":178900521,"number":54,"title":"400 errors don't raise APIError","user":{"login":"candlerb","id":44789,"avatar_url":"https://avatars.githubusercontent.com/u/44789?v=3","gravatar_id":"","url":"https://api.github.com/users/candlerb","html_url":"https://github.com/candlerb","followers_url":"https://api.github.com/users/candlerb/followers","following_url":"https://api.github.com/users/candlerb/following{/other_user}","gists_url":"https://api.github.com/users/candlerb/gists{/gist_id}","starred_url":"https://api.github.com/users/candlerb/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/candlerb/subscriptions","organizations_url":"https://api.github.com/users/candlerb/orgs","repos_url":"https://api.github.com/users/candlerb/repos","events_url":"https://api.github.com/users/candlerb/events{/privacy}","received_events_url":"https://api.github.com/users/candlerb/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2016-09-23T15:03:30Z","updated_at":"2016-09-23T15:03:30Z","closed_at":null,"body":"Under some circumstances (e.g. you attempt to disconnect a non-existent station), the API returns a meaningful and parseable response - here tested with [unifi_sh_api](https://dl.ubnt.com/unifi/5.2.7/unifi_sh_api)\r\n\r\n~~~\r\n{ \"data\" : [ ] , \"meta\" : { \"mac\" : \"xx:xx:xx:xx:xx:xx\" , \"msg\" : \"api.err.UnknownStation\" , \"rc\" : \"error\"}}\r\n~~~\r\n\r\nHowever since this is also accompanied by a 400 status code, unifi-api does not return this message, but instead just a lower-level HTTP error:\r\n\r\n~~~\r\n$ ./unifi-disconnect-client -c localhost -u admin -p password -v v5 xx:xx:xx:xx:xx:xx -d\r\nDEBUG:unifi.controller:Controller for https://localhost:8443/\r\nDEBUG:unifi.controller:login() as admin\r\nDEBUG:unifi.controller:_mac_cmd(xx:xx:xx:xx:xx:xx, kick-sta)\r\nDEBUG:unifi.controller:_run_command(kick-sta)\r\nTraceback (most recent call last):\r\n  File \"./unifi-disconnect-client\", line 25, in <module>\r\n    c.disconnect_client(mac)\r\n  File \"/home/nsrc/unifi-api/unifi/controller.py\", line 273, in disconnect_client\r\n    self._mac_cmd(mac, 'kick-sta')\r\n  File \"/home/nsrc/unifi-api/unifi/controller.py\", line 240, in _mac_cmd\r\n    self._run_command(command, params, mgr)\r\n  File \"/home/nsrc/unifi-api/unifi/controller.py\", line 233, in _run_command\r\n    return self._read(self.api_url + 'cmd/' + mgr, urllib.urlencode({'json': json.dumps(params)}))\r\n  File \"/home/nsrc/unifi-api/unifi/controller.py\", line 120, in _read\r\n    res = self.opener.open(url, params)\r\n  File \"/usr/lib/python2.7/urllib2.py\", line 410, in open\r\n    response = meth(req, response)\r\n  File \"/usr/lib/python2.7/urllib2.py\", line 523, in http_response\r\n    'http', request, response, code, msg, hdrs)\r\n  File \"/usr/lib/python2.7/urllib2.py\", line 448, in error\r\n    return self._call_chain(*args)\r\n  File \"/usr/lib/python2.7/urllib2.py\", line 382, in _call_chain\r\n    result = func(*args)\r\n  File \"/usr/lib/python2.7/urllib2.py\", line 531, in http_error_default\r\n    raise HTTPError(req.get_full_url(), code, msg, hdrs, fp)\r\nurllib2.HTTPError: HTTP Error 400: Bad Request\r\nDEBUG:unifi.controller:logout()\r\n~~~\r\n"}}
{"actor":{"display_login":"candlerb"}}