Reputation: 1
I am trying to upload annotation files to the CVAT server using the REST API.Here is the code. But the response of session.put(f'{cvat_url}/api/tasks/{task_id}/annotations/', files=files, params=params) is 403. Is this code incorrect?
def upload_task_annotations(cvat_url, username, password, task_id, zip_file_path):
session = requests.Session()
payload = {
'username': username,
'password': password
}
headers = {
'Content-Type': 'application/json'
}
response = session.post(f'{cvat_url}/api/auth/login', json=payload, headers=headers)
response.raise_for_status()
print(response.status_code) # response is 200
with open(zip_file_path, 'rb') as f:
files = {
'annotation_file': (os.path.basename(zip_file_path), f, 'application/zip')
}
params = {
'format': 'CVAT for images 1.1'
}
response = session.put(f'{cvat_url}/api/tasks/{task_id}/annotations/', files=files, params=params)
print(response.status_code) # response is 403
return response.status_code
Best regards.
The cvat-cli command was able to upload the data.
Upvotes: 0
Views: 381