Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

API access for beginners #616

Open
PatrickKiefer93 opened this issue Nov 9, 2023 · 1 comment
Open

API access for beginners #616

PatrickKiefer93 opened this issue Nov 9, 2023 · 1 comment

Comments

@PatrickKiefer93
Copy link

I try to use the API of coco annotator. I am new in this topic and I do not really find a helpful documentation.
I just want to load an image and its coco annotation to coco-annotator from a python script.

But already the first command does not work, followed by error message:

{"success": false, "message": "Authorization required"}

I tried to get authorization with my limited knowledge about API and Swagger but without success.
How can I get authorization and send commands? Maybe some examples in python would be very helpful.

Thank you.

@mibejjh
Copy link

mibejjh commented Jul 8, 2024

I had same issue about Authorization required error and Finally I found out how I can use rest api with authorization.
You will get an authorization information in cookie of response from login request.
You just need to call rest api with cookie that you received from login requests.

import requests
base_url = "http://localhost:5000/api/"
login_res = requests.post(base_url + "user/login", json={"username":"admin", "password": "password"})
res = requests.post(base_url+"category/", json= {"name":"test"}, cookies = login_res.cookies)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants