From 3fd3f3d0fb8f945f976d5cb1a8a8dbf44dd1ed82 Mon Sep 17 00:00:00 2001 From: Adrian Moennich Date: Tue, 20 Aug 2019 12:17:40 +0200 Subject: [PATCH] URSH: Always include /api/ for API calls --- ursh/indico_ursh/util.py | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/ursh/indico_ursh/util.py b/ursh/indico_ursh/util.py index 8484f6a..46c2c60 100644 --- a/ursh/indico_ursh/util.py +++ b/ursh/indico_ursh/util.py @@ -27,12 +27,10 @@ def _get_settings(): def request_short_url(original_url): api_key, api_host = _get_settings() headers = {'Authorization': 'Bearer {api_key}'.format(api_key=api_key)} - url = posixpath.join(api_host, 'urls/') + url = posixpath.join(api_host, 'api/urls/') response = requests.post(url, data={'url': original_url, 'allow_reuse': True}, headers=headers) - if response.status_code not in (400,): - response.raise_for_status() - + response.raise_for_status() data = response.json() return data['short_url'] @@ -40,7 +38,7 @@ def request_short_url(original_url): def register_shortcut(original_url, shortcut): api_key, api_host = _get_settings() headers = {'Authorization': 'Bearer {api_key}'.format(api_key=api_key)} - url = posixpath.join(api_host, 'urls', shortcut) + url = posixpath.join(api_host, 'api/urls', shortcut) response = requests.put(url, data={'url': original_url, 'allow_reuse': True}, headers=headers) if not (400 <= response.status_code < 500):