mirror of
https://github.com/lucaspalomodevelop/indico-plugins.git
synced 2026-03-13 07:29:39 +00:00
URSH: Always include /api/ for API calls
This commit is contained in:
parent
2b831d7ef8
commit
3fd3f3d0fb
@ -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):
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user