Getting a "Client Error" when attempting to retrieve projects from Label-studio

76 Views Asked by At

I am trying to fetch all the current projects from the Label-studio, here functions check_connection & get_session work just fine, however, I am getting the following error while fetching the projects using get_projects:

Code:

from label_studio_sdk import Client

LABEL_STUDIO_URL = 'http://xx.xxx.xx.xxx:xxxx'
API_KEY = 'a6eecde17b14b768085a67a6657c44fac5e0244d'

ls = Client(url=LABEL_STUDIO_URL, api_key=API_KEY)
print(ls.check_connection())  # WORKS
print(ls.get_session())  # WORKS

print(ls.get_projects())  # DOES NOT WORK

Error:

{'status': 'UP'}
<requests.sessions.Session object at 0x7f85f818a8b0>


Traceback (most recent call last):
  File "/path/to/neuron-de-yolo/label_studio/test.py", line 18, in <module>
    print(ls.get_projects())
  File "/opt/anaconda3/lib/python3.9/site-packages/label_studio_sdk/client.py", line 143, in get_projects
    return self.list_projects()
  File "/opt/anaconda3/lib/python3.9/site-packages/label_studio_sdk/client.py", line 181, in list_projects
    response = self.make_request(
  File "/opt/anaconda3/lib/python3.9/site-packages/label_studio_sdk/client.py", line 374, in make_request
    response.raise_for_status()
  File "/opt/anaconda3/lib/python3.9/site-packages/requests/models.py", line 1021, in raise_for_status
    raise HTTPError(http_error_msg, response=self)
requests.exceptions.HTTPError: 401 Client Error: Unauthorized for url: http://xx.xxx.xx.xxx:xxxx/api/projects?page_size=10000000
1

There are 1 best solutions below

0
On

Make sure to remove api/projects/ from your LABEL_STUDIO_URL. This might be the issue