Example how to send shipment to openrouteservice optimization API endpoint

I am trying to utilize openrouteservice optimization endpoint, but I need an example. All examples are related to Jobs function, but I can’t find any related to Shipment. Here is a part that I managed so far:

	vehicles = []
	for idx, coords in enumerate(vehicle_locations):
			vehicles.append(ors.optimization.Vehicle(
					id=idx,
					profile='driving-car',
					start=coords,
					end=coords,
					capacity=[300]  # Limit capacity so only 3 jobs can be taken by each vehicle
			))
			folium.Marker(location=list(reversed(coords)), icon=folium.Icon(icon='truck', prefix='fa')).add_to(m)

	shipments=[]
	for idx, coords in enumerate(shipment_locations):
			pickup = dict(id=idx, location = coords, description = "load", amount=[1] )
			delivery = dict(id=idx, location = coords, description = "unload", amount=[1] )
			shipments.append(ors.optimization.Shipment(
					pickup=pickup,
					delivery=delivery
			))
			folium.Marker(location=list(reversed(coords)), icon=folium.Icon(icon='archive', prefix='fa', color='green')).add_to(m)

	optimized = client.optimization(
			shipments=shipments,
			vehicles=vehicles,
			geometry=True,  ## will output the geometry,
	)

The error what I am getting is:
Exception has occurred: AssertionError
exception: no description

Is there any working example of how to properly assemble shipments?

Hi @sogrbilja,

there shouldn’t be any assertion outside of testing code. Could you provide the full stack trace please.
Also you can take a look at the optimization test of the ors-py package for an example.

Best regards

Thanks, I figure out what was my mistake. I debug line by line until I didn’t find that I was missing some variables. Once all variables were passed then it worked.

Can you please share how you fixed it?