diff options
| author | 2018-02-11 18:38:46 +0000 | |
|---|---|---|
| committer | 2018-02-11 18:38:46 +0000 | |
| commit | d328cf3e14179afe673f9bce18b8474b071893cf (patch) | |
| tree | 38bef3619230544dfa13d78f3962332e04dec276 | |
| parent | [Asana] Supply bearer token to API calls (diff) | |
[Asana] Raise for status properly
| -rw-r--r-- | pysite/views/api/asana.py | 10 | 
1 files changed, 6 insertions, 4 deletions
| diff --git a/pysite/views/api/asana.py b/pysite/views/api/asana.py index 9cac5f38..a76c8052 100644 --- a/pysite/views/api/asana.py +++ b/pysite/views/api/asana.py @@ -88,16 +88,16 @@ class IndexView(APIView):          session = requests.session()          session.headers["Authorization"] = f"Bearer {ASANA_TOKEN}" -        resp = session.get(f"{STORY_URL}/{resource}").json() +        resp = session.get(f"{STORY_URL}/{resource}")          resp.raise_for_status()          story = resp.json()          if story.get("type") == "comment" and action == "added":  # New comment! -            resp = session.get(f"{TASK_URL}/{parent}").json() +            resp = session.get(f"{TASK_URL}/{parent}")              resp.raise_for_status()              task = resp.json() -            resp = session.get(f"{USER_URL}/{user}").json() +            resp = session.get(f"{USER_URL}/{user}")              resp.raise_for_status()              user = resp.json() @@ -138,7 +138,9 @@ class IndexView(APIView):          task = resp.json()          if action == "changed":  # New comment! -            user = session.get(f"{USER_URL}/{user}").json() +            resp = session.get(f"{USER_URL}/{user}") +            resp.raise_for_status() +            user = resp.json()              if user["photo"]:                  photo = user["photo"]["image_128x128"] | 
