Error Handling
This page explains how DM Web Services communicates errors, the difference between HTTP-level and application-level failures, and how to handle them in both REST and SOAP integrations.
Two Layers of Errors
DM Web Services reports errors at two distinct levels. Understanding the difference is essential for correct error handling.
| Layer | HTTP Code | When It Occurs | Body |
|---|---|---|---|
| Transport / Auth | 401 | Missing or invalid token | No body |
| Application | 200 | Validation failure, business rule violation, carrier API error | JSON / SOAP body with status: "Error" |
An HTTP 200 response does not mean the operation succeeded -- always check the status field.
REST Error Responses
HTTP 401 -- Authentication Failure
Returned when the token is missing, expired, or invalid. No response body.
HTTP/1.1 401 Unauthorized
HTTP 200 -- Application Error
Returned for validation failures and business rule violations. Always check status.
{
"status": "Error",
"dmLoadNumber": 0,
"shipmentGUID": null,
"carrierProNumber": null,
"errors": [
"ClientReferenceCode is required.",
"Consignee.Address1 is required."
]
}
Recommended REST Handling Pattern
if HTTP_STATUS == 401:
# Token issue -- stop and alert, do not retry automatically
raise AuthenticationError
response_body = parse_json(HTTP_BODY)
if response_body.status == "Error":
# Application-level error -- log errors array, handle per business rules
for error in response_body.errors:
log(error)
else:
# Success -- use dmLoadNumber for subsequent calls
load_number = response_body.dmLoadNumber
SOAP Error Responses
HTTP 401 -- Authentication Failure
Returns HTTP 401 at the transport level. The SOAP body is not reached. No SOAP fault is returned.
HTTP/1.1 401 Unauthorized
HTTP 200 -- Application Error (Status = Error in result)
Validation and business rule errors are returned inside the SOAP result element, not as SOAP faults.
<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
<s:Body>
<CreateShipmentResponse xmlns="http://dmwebservices.com/shipping/public/v1">
<result>
<Status>Error</Status>
<DMLoadNumber>0</DMLoadNumber>
<ShipmentGUID i:nil="true" xmlns:i="http://www.w3.org/2001/XMLSchema-instance"/>
<CarrierProNumber i:nil="true" xmlns:i="http://www.w3.org/2001/XMLSchema-instance"/>
<Errors xmlns:a="http://schemas.microsoft.com/2003/10/Serialization/Arrays">
<a:string>ClientReferenceCode is required.</a:string>
<a:string>Consignee.Address1 is required.</a:string>
</Errors>
</result>
</CreateShipmentResponse>
</s:Body>
</s:Envelope>
SOAP Fault -- Unexpected Server Error
An unhandled server-side exception produces a SOAP fault. This is distinct from an application-level error and should not occur under normal operation.
<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
<s:Body>
<s:Fault>
<faultcode>s:Server</faultcode>
<faultstring>Internal server error.</faultstring>
</s:Fault>
</s:Body>
</s:Envelope>
If you receive a SOAP fault, contact your DM integration coordinator with the timestamp and request details.
Common Error Messages
| Error Message | Cause | Resolution |
|---|---|---|
ClientReferenceCode is required. | Field missing or empty | Provide the client code issued by DM |
Client not found. | ClientReferenceCode does not match any active client | Verify the code with DM |
Carrier not found. | CarrierReferenceCode not recognized or not authorized for this client | Verify the carrier code with DM |
Service level not recognized. | ServiceLevelCode not in the carrier's valid service level list | Check the carrier's supported service levels with DM |
Consignee address is required. | Consignee block missing or incomplete | Supply Name, Address1, City, State, Zip, Phone |
At least one line item is required. | LineItems array is empty | Include at least one LineItem with Pieces and Weight |
Shipment X already has a carrier PRO number assigned. | BookLastMile called on a shipment already booked | Do not re-book; use the existing PRO number |
Shipment not found. | DMLoadNumber not found or not accessible by this client | Verify the load number; confirm it belongs to your client account |
ASN data incomplete. | FinalMile booking missing Expected at Terminal date or 1st Leg references | Supply all required ASN references and dates before calling BookLastMile |
Beyond Client Error Responses
Beyond client operations use a simpler response structure. Status codes vary by operation -- see each function's documentation for specifics.
{
"status": "Error",
"message": "SKU not found in warehouse."
}
Beyond operations return HTTP 400 (bad request) or 409 (conflict) on failure rather than always 200. Check the HTTP status code in addition to the response body.