主要内容

本页采用了机器翻译。点击此处可查看最新英文版本。

排除 RESTful API 错误

由于客户端与 MATLAB® Production Server™ 之间的通信是通过 HTTP 进行的,因此许多错误都由 HTTP 状态代码指示。部署的 MATLAB 函数中的错误使用不同的格式。有关详细信息,请参阅MATLAB 错误的结构体。要查看 RESTful API 的使用情况,请参阅 用于 MATLAB 函数执行的 RESTful API

HTTP 错误的结构体

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

HTTP 状态代码

400 - 错误请求

消息描述
Invalid input客户端请求的格式不正确。
Invalid JSON客户端请求不包含有效的 JSON 表示。
nargout missing客户端请求未指定包含输出参量的 nargout
rhs missing客户端请求未指定包含输入参量的 rhs
Invalid rhs输入参量不遵循 MATLAB 数据类型的 JSON 表示。有关详细信息,请参阅MATLAB 数据类型的 JSON 表示

403–禁止

消息描述
The client is not authorized to access the requested component客户端没有正确的凭据来发出请求。

404-未找到

消息描述
Function not found服务器无法在部署的 CTF 存档中找到 MATLAB 函数
Component not found服务器无法找到 CTF 存档
URI-path not of form '/APPLICATION/FUNCTION'URL 格式不正确

405 - 方法不允许

消息描述
Bad Method方法不允许
Method must be POST方法不允许
Unsupported method方法不允许

411 - 长度要求

消息描述
Content-length missing内容长度缺失

415 - 不支持的媒体类型

消息描述
<VALUE> is not an accepted content typeJSON 的内容类型不正确。

500 - 内部服务器错误

消息描述
Function return type not supported服务器上部署的 MATLAB 函数返回了 MATLAB Production Server 不支持的 MATLAB 数据类型。有关 MATLAB Production Server 支持的数据类型的信息,请参阅 MATLAB 数据类型的 JSON 表示

资源查询与资源状态

资源/服务器状态

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

MATLAB 错误的结构体

要解决 MATLAB 错误,请对服务器上部署的 MATLAB 函数进行故障排除。

{
  "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
       },
       ...
    ]
  }
}

访问控制允许来源

如果客户端程序从不同的域发出请求,使用 JavaScript® 的客户端程序员需要验证 MATLAB Production Server 实例上是否启用了跨域资源共享 (CORS)。如果未启用 CORS,您可能会收到以下错误消息:

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.

有关如何启用 CORS 的信息,请参阅 cors-allowed-origins

另请参阅

主题