Description
openedon Jan 20, 2024
I use taxii2client.v21 to receive data from OpenCTI, but when receiving the objects from the collection, I get the following error. Has anyone had this problem? I will be happy to help
from taxii2client.v21 import Server, Collection
server = Server(url='http://192.168.204.114:8080/taxii2/', user='user', password='password')
collection_id = '3c42e325-611e-43ae-b789-3f2f8f275596'
api_root = server.api_roots[0]
print(api_root.collections)
desired_collection = None
for collection in api_root.collections:
if collection.id == collection_id:
desired_collection = collection
break
response = desired_collection.get_objects()
print(response)
[<taxii2client.v21.Collection object at 0x7f5b2b4e15a0>, <taxii2client.v21.Collection object at 0x7f5b2b4e1c60>]
Traceback (most recent call last):
File "/home/mrd/TAXII_Server/server 4/cti-taxii-client/test.py", line 21, in
response = desired_collection.get_objects()
File "/home/mrd/TAXII_Server/server 4/cti-taxii-client/venv/lib/python3.10/site-packages/taxii2client/v21/init.py", line 376, in get_objects
return self._conn.get(self.objects_url, headers={"Accept": accept}, params=query_params)
File "/home/mrd/TAXII_Server/server 4/cti-taxii-client/venv/lib/python3.10/site-packages/taxii2client/common.py", line 319, in get
raise TAXIIServiceException(msg.format(content_type, accept))
taxii2client.exceptions.TAXIIServiceException: Unexpected Response. Got Content-Type: 'application/json; charset=utf-8' for Accept: 'application/taxii+json;version=2.1'
If you are trying to contact a TAXII 2.0 Server use 'from taxii2client.v20 import X'
If you are trying to contact a TAXII 2.1 Server use 'from taxii2client.v21 import X'
and
from taxii2client.v21 import Server, Collection
server = Server(url='http://192.168.204.114:8080/taxii2/', user='user', password='password')
collection_id = '3c42e325-611e-43ae-b789-3f2f8f275596'
api_root = server.api_roots[0]
print(api_root.collections)
desired_collection = None
for collection in api_root.collections:
if collection.id == collection_id:
desired_collection = collection
break
response = desired_collection.get_objects(accept='application/json; charset=utf-8')
print(response)
[<taxii2client.v21.Collection object at 0x7fce28bed600>, <taxii2client.v21.Collection object at 0x7fce28bedcc0>]
Traceback (most recent call last):
File "/home/mrd/TAXII_Server/server 4/cti-taxii-client/test.py", line 21, in
response = desired_collection.get_objects(accept='application/json; charset=utf-8')
File "/home/mrd/TAXII_Server/server 4/cti-taxii-client/venv/lib/python3.10/site-packages/taxii2client/v21/init.py", line 376, in get_objects
return self._conn.get(self.objects_url, headers={"Accept": accept}, params=query_params)
File "/home/mrd/TAXII_Server/server 4/cti-taxii-client/venv/lib/python3.10/site-packages/taxii2client/common.py", line 319, in get
raise TAXIIServiceException(msg.format(content_type, accept))
taxii2client.exceptions.TAXIIServiceException: Unexpected Response. Got Content-Type: 'application/json; charset=utf-8' for Accept: 'application/json; charset=utf-8'
If you are trying to contact a TAXII 2.0 Server use 'from taxii2client.v20 import X'
If you are trying to contact a TAXII 2.1 Server use 'from taxii2client.v21 import X'