Hello group,
A lot of the answers here have helped me through getting different aspects of the code to work, but for whatever reason I am having a difficult time writing a patch to forge a relationship between two objects. In the code example below I am creating a new object and returning the object's id as a new variable. I am then attempting to forge a relationship between that new domain and an actor whose ID I am hard coding into the script for testing purposes. Running the code returns the following error:
{"message": "Could not find relationship type", "type": "Actor", "return_code":
1, "id": "593576213a044e5646baa191"}
Could anyone point me in the right direction?
Bonus question when looking at the handler for relationships can someone point me in the direction on how to figure out the class for right_class and class_? I feel like that will be my next big hurdle.
Thank you!
Nate
Example Code
import requests
import json
import datetime
data = {
'api_key': 'REDACTED',
'username': 'testuser',
'source': 'Test',
'ip': '127.0.0.2'
}
event_id = r.json().get('id')
params = {
'api_key' : 'REDACTED',
'username' : 'testuser'
}
headers = {
'Content-Type' : 'application/json',
}
# date must be in the format %Y-%m-%d %H:%M:%S.%f
formatted_date = datetime.datetime.now().strftime('%Y-%m-%d %H:%M:%S.%f')
data = {
'action' : 'forge_relationship',
'right_type': 'Domain',
'right_id': event_id,
'type_': 'Actor',
'id_': '593576213a044e5646baa191'
}
r = requests.patch(submit_url, headers=headers, params=params, data=json.dumps(data), verify=False)