Page tree

Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

此文档描述了Vnnox系统的REST API(v1),如果您在使用中有任何问题请及时联系

Anchor
banben
banben
版本

默认情况下当客户端访问https://cn.vnnox.com时,系统将使用V1 版REST API提供服务,我们建议您在http请求的heaer中的`Accept`字段加上服务版本号。格式如下:

Code Block
firstline1
titleAcceptHTTP header
linenumberstrue
Accept:application/nova.vnnox.v1+json

...

所有请求均通过HTTPS协议,API请求链接为https://cn.vnnox.com,所有数据的请求及相应均通过json格式。

Request Header

Code Block
firstline1
titleHTTP Request Header
linenumberstrue
Content-Type:application/json;charset=utf-8


Response数据结构

Code Block
firstline1
titledata structure
linenumberstrue
collapsetrue
{
    "http_code": 200,            //http状态码(重要:请使用http协议本身的状态码做异常捕获,response data中http_code字段后期会取消掉)
    "data": {...some data...},   //数据部分
    "status": [10000001]         //业务相关状态码
}

...

如上面的例子,本文档所有涉及{host}均指https://cn.vnnox.com/,建议第三方开发者将com,建议第三方开发者将{host}信息作为可配置项

错误调试
Anchor
cuowu
cuowu

...

1、服务级错误:网络或运营商导致的服务级别错误。(建议第三方应用中捕获http不等于2xx的状态码,如404、502等)


Code Block
firstline1
HTTP/1.1 502 Bad Gateway


2、系统级错误:REST API 请求中传入了非法参数或者数据格式错误。(建议第三方在应用中捕获 json.status[0] = 1)

Code Block
firstline1
HTTP/1.1 200 ok

{
    "data": "系统级错误,请联系VNNOX管理员,谢谢!",
    "status": [1]
}

3、业务级错误:REST API因业务限制返回的状态码/错误码(json.status)。(建议第三方应用根据状态码说明处理API结果)

Code Block
firstline1
HTTP/1.1 200 ok

{
    "http_code": 200,
    "data": {
        "roleName": ""
    },
    "status": [50101201]
}


HTTP方法
Anchor

...

htt

...

htt

Vnnox REST API 目前支持4中HTTP方法:

...

Code Block
firstline1
titleRequest HeaderHTTP header
token:5c1354529946bc49360641f7f321611698deb371

...

使用Oauth2.0认证的REST API访问,同一个用户获取的token访问频次建议1小时内不要超过3000次。

Anchor
daili
daili
用户代理

所有的API请求一般都会包含User-Agent header,例如浏览器会默认设定为`Mozilla/5.0`等,如果第三方应用对接VNNOX REST API,请参照如下设置:

Code Block
firstline1
titleHTTP header
User-Agent: Vnnox-User-App

如果应用的HTTP请求中没有此参数设定,系统无法验证当前用户的Request请求来源,可能会影响到数据的访问。