I use add_attribute but i have a error in this func.
line 779, in add_attribute if ('errors' in new_attribute and new_attribute['errors'][0] == 403 KeyError: 0
I add attributes in multiple using add_attribute (I give a list to value) and I get the error I show above. I show the reason for this below.
Something went wrong (403): {'saved': False, 'name': 'Could not add Attribute', 'message': 'Could not add Attribute', 'url': '/attributes/add', 'errors': {'attribute_0': {'value': ['A similar attribute already exists for this event.']}, 'attribute_1': {'value': ['A similar attribute already exists for this event.']}, 'attribute_2': {'value': ['A similar attribute already exists for this event.']}, 'attribute_3': {'value': ['A similar attribute already exists for this event.']}}}
Do you have duplicate attributes in your list? If so, you might want to check out this on https://www.misp-project.org/2023/04/13/MISP.2.4.170.released.html/ which was requested in https://github.com/MISP/MISP/issues/5257
Fixes
- Add support for a
breakOnDuplicatenamed parameter on/attributes/addendpoint, default value is true which keeps the current behavior of throwing an error when the user tries to add duplicate attribute to an event. When set to false the endpoint will work as an upsert, updating the attributes timestamp and any other properties provided in the payload, no error logs will be written.
TY!