is not of type 'NodeMixin'. -Python Anytree

694 Views Asked by At

I am getting the following error when i try to use a json a value of the Parent node using the anytree module, How can I get the json value as a parent?

Here is my code

def Get_Full_Name():
    name = names.get_full_name()
    return name


def Type_Name():
    ListType = ['Room', 'Building', 'Bed']
    number = random.sample([int(x) for x in range(1, 3)], 1)
    RandomList = ListType[number[0]]
    return RandomList



headers = {
    'accept': 'text/plain',
    'Content-Type': 'application/json-patch+json',
}

name = Get_Full_Name()
ListValue = Type_Name()
params = (
    ('name', name),
    ('type', 'BuildingGroup'),
)

data = '["{}"]'.format(name)

response = requests.post('http://SampleApiURL/', headers=headers,
                         params=params, data=data)


response_body = response.json()
print("Parent: " + response_body)
headers = {
    'accept': 'text/plain',
}

response2 = requests.get('http://SAmpleApiUrl/' + response_body, headers=headers)

response_body1 = response2.json()
RootNode = AnyNode(response_body1)
#ChildL2 = AnyNode(response_content="someValue", parent=RootNode)

exporter = JsonExporter(indent=4, sort_keys=True)
print  (exporter.export(RootNode))

The error I am getting is

Parent node {'locationId': 'LocationId', 'name': 'Andrew Rice', 'type': 'BuildingGroup', 'patientId': None, 'children': None} is not of type 'NodeMixin'.

How can I use a Json as a parent Node?

0

There are 0 best solutions below