Main Content

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. See Structure of MATLAB Error for more information. To review API usage, see RESTful API.

HTTP Status Codes

400–Bad Request

MessageDescription
Invalid inputClient request is not formatted correctly.
Invalid JSONClient request does not contain a valid JSON representation.
nargout missingClient request does not specify nargout containing output arguments.
rhs missingClient request does not specify rhs containing input arguments.
Invalid rhsInput arguments does not follow the JSON representation for MATLAB data types.

403–Forbidden

MessageDescription
The client is not authorized to access the requested componentClient does not have the correct credentials to make a request.

404–Not Found

MessageDescription
Function not foundServer could not find the MATLAB function in the deployed CTF archive.
Component not foundWas unable to find the CTF archive.
URI-path not of form '/APPLICATION/FUNCTION'URL not in the correct format.

405–Method Not Allowed

MessageDescription
Bad MethodMethod is not allowed.
Method must be POSTMethod is not allowed.
Unsupported methodMethod is not allowed.

411–Length Required

MessageDescription
Content-length missingLength of the content is missing.

415–Unsupported Media Type

MessageDescription
<VALUE> is not an accepted content typeDid not set correct content type for JSON.

500–Internal Server Error

MessageDescription
Function return type not supportedMATLAB 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 $request-uri/result

404 - RequestNotFound

204 - NoContent

204 - NoContent

204 - NoContent

200 - OK

200 - OK

410 - RequestAlreadyCancelled

410 - RequestAlreadyDeleted

500 - InternalServerError

POST $request-uri/cancel

404 - RequestNotFound

204 - NoContent

204 - NoContent

204 - NoContent

410 - RequestAlreadyCompleted

410 - RequestAlreadyCompleted

410 - RequestAlreadyCancelled

410 - RequestAlreadyDeleted

500 - InternalServerError

DELETE $request-uri

404 - RequestNotFound

409 - RequestNotCompleted

409 - RequestNotCompleted

409 - RequestNotCompleted

204 - NoContent

204 - NoContent

204 - NoContent

410 - RequestAlreadyDeleted

500 - InternalServerError

Structure of MATLAB Error

In order to resolve a MATLAB error, you will need to 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
       },
       ...
    ]
  }
}

Structure of HTTP Error

{ 
    "error": { 
        "type": "httperror", 
        "code": 404, 
        "messageId": "ComponentNotFound", 
        "message": "Component not found." 
    } 
}

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 will be making 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.

Related Topics