- I was testing api getDistanceMatrix by sending below request as per the documentation
Code: Select all
{ "id": "1352f670-b601-4845-9669-4098368601e3" }
- But it shows an error as shown below
Code: Select all
{ "message": "Cannot construct instance of `com.ptvgroup.xserver.xdima.GetDistanceMatrixRequest` (no Creators, like default constructor, exist): abstract types either need to be mapped to concrete types, have custom deserializer, or contain additional type information\n at [Source: (org.apache.cxf.transport.http.AbstractHTTPDestination$1); line: 3, column: 1]", "errorLine": 3, "errorColumn": 1, "faultType": "com.ptvgroup.xserver.exceptions.InvalidRequestFault" }
- The xDima2.GetDistanceMatrixRequest is an abstract class which you can't instanciate.
- Instead you have to use one of it's derived child classes - in this case either GetDistanceMatrixByLocationsRequest or GetDistanceMatrixByRelationsRequest
- For the JSON request this means that you have to qualify the type, e.g. the GetDistanceMatrixByLocationsRequest:
Code: Select all
{ "id": "1352f670-b601-4845-9669-4098368601e3", "$type": "GetDistanceMatrixByLocationsRequest" }
- This will then lead to the next obstacle: the specific class requires two attributes which are supposed to be given...
Code: Select all
{ "faultInfo": { "$type": "InvalidValueFault", "hint": "Affects field 'startLocations' in 'GetDistanceMatrixByLocationsRequest'.", "parameter": "/GetDistanceMatrixByLocationsRequest/startLocations" }, "message": "List must have at least 1 item(s) but was missing." }
- So to get rid of this second error please ensure to provide all required parameters of the child class in use