Error condition
An error condition occurs when a user is not authorized to call your web service or your service is not able to complete successfully.
An error condition occurs when a user is not authorized to call your web service or your service is not able to complete successfully.
In case of an error condition, your web service should return an HTTP 400-level or 500-level status code. Depending on the HTTP status code, you can also provide a top-level XML element and associated structure for error codes and messages in the response body.
Please note that you will return either the normal output data (under a top level XML element, as appropriate) or the error XML structure, or neither (depending on the nature of the error).
Examples
Sample REST request
GET https:///ValidateRsa/99999999999999? AdditionalInfo=PO123-45678- XY&RsaNumberIssueDate=2012-09-22 HTTP/1.1
Sample REST - XML Response
HTTP/1.1 200 Good
Content-Type: application/canadapost.rsa+xml
<?xml version=”1.0” encoding=”UTF-8”?>
<?ns1:ValidateRsaResponse xmlns:ns1=”http://www.canadapost.ca/webservices/validatersa”>
<ValidationStatus>true</ValidationStatus>
</ns1:ValidateRsaResponse>
Sample REST - XML Response to an error condition
HTTP/1.1 500 Error
Content-Type: application/canadapost.rsa+xml
<?xml version=”1.0” encoding=”UTF-8”?>
<ns2:Messages xmlns:ns2=”http://www.canadapost.ca/webservices/messages”>
<Message>
<Code>8304</Code>
<Description>Sample error</Description>
</Message>
</ns2:Messages>
Sample REST - JSON Response
HTTP/1.1 200 Good
Content-Type: application/candapost.rsa+json
{
"ValidateRsaResponse":{ "ValidationStatus":true
}
}
Sample REST - JSON Response to an error condition
HTTP/1.1 500 Error
Content-Type: application/candapost.rsa+json
{
"Messages":[
{ "Code":"8304", "Description":"Sampleerror"
}
]
}