In ArcGIS REST APIs, routing services are used to perform analysis on transportation networks and each service can be accessed using a unique REST endpoint for the service including the Route and the origin-destination (OD) cost matrix services. Both services can be used to calculate the distance between locations of a network, such as roads.
The Route and OD cost matrix services can sometimes return different results when calculating the distance between Point A to Point B even though all the parameters used are identical including the travelMode or impedanceAttributeName parameters.
This is by design when using different routing services during analysis. The Route service focuses more on finding the best routes and directions to get from one location to another, considering factors such as time, traffic, and distance. The OD cost matrix service creates a travel cost table, focusing more on the cost, such as travel time or distance from origin to each destination. Even if the lines of the route are straight, this service considers the travel time and distance based on the network. Thus, slight differences in their outputs are expected.
Although the difference in the distance result is sometimes less noticeable because of the shorter-distance hierarchical routes, it is more noticeable for longer-distance hierarchical routes. These differences become more significant if two locations become more distant from the other on the network. This is because a hierarchy uses a heuristic to reduce the computation time by limiting the search mostly to higher levels of the hierarchy. Thus, the distance results returned from the Route and OD cost matrix services are different because they each have different search algorithms, techniques, and purposes when performing the analysis.