API:发起模型对比
POST https://api.bimface.com/compare
不同版本的模型文件上传并转换成功后,即可发起模型对比。由于对比不能立即完成,BIMFace支持在模型对比完成以后,通过Callback机制通知应用;另外,应用也可以通过接口查询对比状态。
请求(Request)
Header
key | value | 示例 |
---|---|---|
Authorization | bearer {accessToken} | bearer xxxx-xxxx-xxxx-xxxx |
Content-Type | application/json | … |
Url Parameter
无
Request Body
{
"sources": [{
"previousFileId":1876324981274,
"followingFileId":876435982734
}],
"sourceId":"第三方的id",
"name":"我的对比模型",
"priority": 2,
"callback": "http://callback.url"
}
字段 | 类型 | 必填 | 描述 | 示例 |
---|---|---|---|---|
previousFileId | Number | N | 变更前文件ID,如果为新增文件,则为null | 857482189666208 |
followingFileId | Number | N | 变更后文件ID,如果为删除文件,则为null | 857482189666209 |
sources | Source[] | Y | 数组,多个CompareSource,待对比的文件 | … |
name | String | N | 用户指定对比后的模型的名字 | |
sourceId | String | N | 第三方应用自己的ID | |
priority | Number | 优先级,数字越大,优先级越低 | 1, 2, 3 | |
callback | String | N | Callback地址,待对比完毕以后,BIMFace会回调该地址 | http://www.app.com/receive |
响应(Response)
HTTP STATUS
200
{
"code": "success",
"message": null,
"data": {
"compareId": 85929027838566,
"status": "processing",
"priority":2,
"thumbnail":null,
"reason": null,
"createTime": "2015-08-08 12:23:11"
}
}
字段 | 类型 | 描述 | 示例 |
---|---|---|---|
compareId | Number | 对比ID | 857482189666208 |
status | String | 对比状态 | prepare(待对比)、processing(对比中)、success(对比成功)、failed(对比失败) |
priority | Number | 对比任务优先级 | 2 |
reason | String | 若对比失败,返回失败原因 | … |
createTime | String | 对比开始时间,格式:yyyy-MM-dd hh:mm:ss | 2016-10-14 14:29:16 |
失败返回
{
"code": "authentication.failed",
"message": "Token was not recognized."
}
错误码
code | 说明 |
---|---|
system.error | BIMFace系统异常 |
authentication.failed | API访问合法性校验失败 |
file.not.found | 对比文件不存在 |
回调(Callback)
待BIMFace对比完毕后,根据应用传入的回调地址,BIMFace会通知对比结果,对比可能成功、也可能失败。
Method
GET
Header
key | value | 示例 |
---|---|---|
Content-Type | application/json | … |
Url Parameter
字段 | 类型 | 描述 | 示例 |
---|---|---|---|
compareId | Number | 模型对比ID | 857482189666208 |
status | String | 模型对比状态 | success(模型对比成功)、failed(模型对比失败) |
reason | String | 若对比失败,则返回失败原因 | … |
thumbnail | String | 模型对比模型的缩略图,多个缩略图用“,”分隔(如果有缩略图的话) | … |
nonce | String | 回调随机数 | … |
signature | String | 签名 | … |
signature(签名):为了确保回调消息是由BIMFace发出的,应用在收到回调消息后,须验证签名。签名的计算方式:MD5(“appKey:appSecret:fileId:status:nonce”),如果应用计算的签名与BIMFace返回的签名一致,则证明该消息是安全可靠的。
消息回执
应用收到回调后,须向BIMFace发送回执,回执消息:HTTP STATUS 200