Troubleshooting RESTful API Errors
Since communication between the client and MATLAB® Production Server™ is over HTTP, many errors are indicated by an HTTP status code. Errors in the deployed MATLAB function use a different format. For more information, see Structure of MATLAB Error. To review RESTful API usage, see RESTful API for MATLAB Function Execution.
Structure of HTTP Error
{ "error": { "type": "httperror", "code": 404, "messageId": "ComponentNotFound", "message": "Component not found." } } |
HTTP Status Codes
400–Bad Request
Message | Description |
---|---|
Invalid input | Client request is not formatted correctly. |
Invalid JSON | Client request does not contain a valid JSON representation. |
nargout missing | Client request does not specify nargout containing output
arguments. |
rhs missing | Client request does not specify rhs containing input
arguments. |
Invalid rhs | Input arguments do not follow the JSON representation for MATLAB data types. For more information, see JSON Representation of MATLAB Data Types. |
403–Forbidden
Message | Description |
---|---|
The client is not authorized to access the requested
component | Client does not have the correct credentials to make a request. |
404–Not Found
Message | Description |
---|---|
Function not found | Server is unable to find the MATLAB function in the deployed CTF archive |
Component not found | Server is unable to find the CTF archive |
URI-path not of form '/APPLICATION/FUNCTION' | URL is not in the correct format |
405–Method Not Allowed
Message | Description |
---|---|
Bad Method | Method is not allowed |
Method must be POST | Method is not allowed |
Unsupported method | Method is not allowed |
411–Length Required
Message | Description |
---|---|
Content-length missing | Length of the content is missing |
415–Unsupported Media Type
Message | Description |
---|---|
<VALUE> is not an accepted content type | Content type for JSON is incorrect. |
500–Internal Server Error
Message | Description |
---|---|
Function return type not supported | MATLAB function deployed on the server returned a MATLAB data type that MATLAB Production Server does not support. For information about the data types that the MATLAB Production Server supports, see JSON Representation of MATLAB Data Types. |
Resource Query vs Resource States
Resources / Server States | NOT_FOUND | READING | IN_QUEUE | PROCESSING | READY | ERROR | CANCELLED | DELETED / PURGED | UNKNOWN SERVER ERROR |
---|---|---|---|---|---|---|---|---|---|
GET |
|
|
|
|
|
|
|
|
|
POST |
|
|
|
|
|
|
|
|
|
DELETE |
|
|
|
|
|
|
|
|
|
Structure of MATLAB Error
To resolve a MATLAB error, troubleshoot the MATLAB function deployed on the server.
{ "error": { "type": "matlaberror", "id": error_id, "message": error_message, "stack": [ { "file": file_name1, "name": function_name1, "line": file_line_number1 }, { "file": file_name2, "name": function_name2, "line": file_line_number2 }, ... ] } } |
Access-Control-Allow-Origin
Client programmers using JavaScript® need to verify whether Cross-Origin Resource Sharing (CORS) is enabled on a MATLAB Production Server instance, if their clients programs make requests from different domains. If CORS is not enabled, you may get the following error message:
Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'null' is therefore not allowed access.
For information on how to enable CORS, see cors-allowed-origins.