openlca-python-tutorial icon indicating copy to clipboard operation
openlca-python-tutorial copied to clipboard

Error while creating a flow

Open y-aoub opened this issue 3 years ago • 1 comments

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`

y-aoub avatar Aug 26 '21 19:08 y-aoub

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.

msrocka avatar Aug 27 '21 06:08 msrocka