openlca-python-tutorial
openlca-python-tutorial copied to clipboard
Error while creating a flow
I tried to create a new flow and add it to the database, like this. But, I have the error below even if the id and type are defined. Weird!
PET_LC.id = str(uuid.uuid4())
PET_LC.flow_type = olca.FlowType.PRODUCT_FLOW
PET_LC.name = 'PET_LC'
PET_LC.description = 'PET Bottle Life Cycle'
#items = client.find(olca.FlowProperty, ‘Number of items’)
items = olca.FlowProperty()
items.name = 'Number of items'
items_factor = olca.FlowPropertyFactor()
items_factor.conversion_factor = 1.0
items_factor.flow_property = items
items_factor.reference_flow_property = True
PET_LC.flow_properties = [items_factor]
client.insert(PET_LC)```
`-32602: Invalid params: params must be an object with valid @id and @type`
Seems like the id of the flow property is missing. Also, you need to make sure that the flow property exists in the database before you insert the flow.