Errors
The MyPreferences API responds with appropriate HTTP error statuses with enough information to identify and fix the issue. In addition to the authorization failures, review the help documentation for the specific API's for handling errors by implementing a common and reliable error-handling framework.
401 - Authorization Errors
When a request is rejected due to an authorization failure, the HTTP Status Code 401- Unauthorized is returned with a detailed error description in the body. Here are some of the examples:
The scheme is invalid
This error occurs when authorization scheme is invalid. For example, if the scheme PNAUTHINFO100-SHA256 was sent, the request would be rejected as there is no PNAUTHINFO100 scheme.
The specified date does not match an expected ISO 8601 format
This error occurs when the Issued Timestamp is either not in the expected ISO 8601 encoded format or the date is set in the future. Requests with future dates will be rejected.
The difference between the issued timestamp and the current time is too large
This error occurs when the authorization request has expired. For example, if the expiration window is 60 seconds and the current time is 2015-08-13T12:35:00 and the Issued Timestamp is 2015-08-13T07:00:00. In this case the authorization request has expired and will be rejected.
Missing Authorization Header
This error occurs when a request is sent without an authorization header field.
Unable to authenticate request
This is a generic authorization failure that can be caused by any of the following conditions:
- The authorization field header is incomplete or missing parameters.
- The generated signature does not match the fields defined by the authorization scheme.
- The UserId does not match any known users for the supplied ClientId.
HTTP/1.1 401 UnauthorizedCache-Control: no-cachePragma: no-cacheContent-Type: application/json; charset=utf-8Expires: -1Server: Microsoft-IIS/8.0WWW-Authenticate: PNAUTHINFO3 realm="https://pm.mypreferences.com"X-AspNet-Version: 4.0.30319X-SourceFiles: =?UTF-8?B?QzpcZGV2XE15UHJlZmVyZW5jZXNcU291cmNlXFdlYlxNeVByZWZlcmVuY2VzLlJFU1RcTXlQcmVmZXJlbmNlcy5SRVNUXGFwaVwzXFBOTzRXXFByb2dyYW1z?=X-Powered-By: ASP.NETDate: Fri, 14 Aug 2015 21:22:27 GMTContent-Length: 68{"Message":"Invalid Authorization Header: The scheme is invalid. The scheme should contain either PNAUTHINFO3- or PNAUTHINFO3-HMAC-. For example: PNAUTHINFO3-HMAC-SHA265."}404 - Resource Not Found
A 404 - Resource Not Found status code is returned when you access a URL or a resource that is invalid or currently unavailable. Additionally, this status code is also returned when the ClientId specified in your request is invalid or not found. Please note that this failed request will not supply a message in the body.
HTTP/1.1 404 Not FoundCache-Control: no-cachePragma: no-cacheExpires: -1Server: Microsoft-IIS/8.0X-AspNet-Version: 4.0.30319X-SourceFiles: =?UTF-8?B?QzpcZGV2XE15UHJlZmVyZW5jZXNcU291cmNlXFdlYlxNeVByZWZlcmVuY2VzLlJFU1RcTXlQcmVmZXJlbmNlcy5SRVNUXGFwaVwzXEFDb21wYW55XFByb2dyYW1z?=X-Powered-By: ASP.NETDate: Mon, 17 Aug 2015 17:05:39 GMTContent-Length: 0What made this section unhelpful for you?
Status Codes
200
OK
Everything worked as expected.
400
Bad request
The request was unacceptable, often due to missing a required parameter.
401
Unauthorized
The request was unacceptable, often due to missing a required parameter.
402
Request Failed
The parameters were valid but the request failed.
403
Forbidden
The API key doesnt have permissions to perform the request.
404
Not Found
The requested resource does not exist.
Error Codes
The scheme is invalid
This error occurs when authorization scheme is invalid. For example, if the scheme PNAUTHINFO100-SHA256 was sent, the request would be rejected as there is no PNAUTHINFO100 scheme.
api_error
API errors cover any other type of problem (e.g., a temporary problem with servers), and are extremely uncommon.