APP365 Open API 开辟指南

APP365提供的Open API是典范的RESTful API,让你能十分容易地将本人的使用与APP365停止集成; 你可以在使用顺序中依照本人的需求盘问或修正运单、车辆、车次、客户、司机、收支库信息、运输进程信息、跟踪信息、财政信息等; APP365 Open API接纳JSON作为恳求和呼应的数据款式。

在你思索本人创立与APP365集成的模块时,请先反省“插件东西”栏目中能否曾经提供了相反的模块,以免反复休息。


获取API认证答应

概述

以后的APP365 Open API 仅支持HTTP Basic access authentication认证方法;API挪用衔接必需经过平安的HTTPS衔接;证书信息由一个无效的用户名和其联系关系的API Key构成; 请拜见下节的“启用 APP365 Open API”,以理解怎样获取一个API Key;在挪用时,假如证书有效或许没有提供,效劳器会前往“401未经受权”的呼应。


为用户启用 APP365 Open API

要受权一个用户让其可以挪用API,请依照下列步调操纵:

  • 进入物流零碎,选择菜单项:根底设置->团体材料
  • 在呈现的界面底部的“登录信息”栏目中,点击“API Key”阁下的“天生”按钮,即可天生一个32位的Key
  • 点击整个界面上方的“保管”按钮,保管相干信息
  • 请留意,APP365中挪用API需求提供Client ID到效劳器端停止挪用,请同时记下API Key下方的Client ID
feature1


设置装备摆设权限

在脚色模块中,设置装备摆设指定脚色可以存取的资源和可以实行的举措,让特定的脚色只能拜访与本人相干的资源和举措,包管零碎数据的平安。 在挪用API时,接纳异样地战略来控制用户的拜访权限,假如用户无权拜访指定的资源,则会前往呼应 “403 Forbidden”。


提倡效劳挪用恳求

登录受权

要挪用APP365 API,你需求在实行恳求时,设置Basic HTTP Authorization头部:username:api_key.

假如运用cURL东西,你可以接纳上面两种方法之一恳求登录受权:

经过"--user"参数结构登录受权的头部

curl --user apiUsername:api_key

经过"--header"参数间接设置登录受权的头部

curl --header "Authorization: Basic YWRtaW46WW91ckFQSUtleUhlcmU="


效劳挪用

APP365 Open API接纳JSON作为恳求和呼应的数据款式,API分为三品种型,盘问数据、保管数据、删除数据:

盘问数据

查找单条记载URL:http://biz.app365.com/bizweb/services/bizobjects

/m56.Barcode /* 实体模子id */
/{id}?fields=station_name,barcodes /* 记载id及其要盘问前往的字段列表*/

盘问列表URL: http://biz.app365.com/bizweb/services/query

/ilms.LmsOrder.selectForList /* 要实行的SqlId */
/"o.name": 'lgh', "o.code": 'fff'/0,100 /* 盘问条件参数,盘问记载的offset limit*/

完好的恳求举例:

curl --request GET \
--header "Authorization: Basic YWRtaW46WW91ckFQSUtleUhlcmU=" \
http://biz.app365.com/bizweb/services/bizobjects/m56.Barcode/{id}?fields=station_name,barcodes
curl --request GET \
--header "Authorization: Basic YWRtaW46WW91ckFQSUtleUhlcmU=" \
http://biz.app365.com/bizweb/services/query/ilms.LmsOrder.selectForList/ \
"o.name": 'lgh', "o.code": 'fff'/0,100

保管数据

保管整个工具的URL: http://biz.app365.com/bizweb/services/bizobjects/m56.Barcode/,同时post一个json工具

更新几个字段的URL:http://biz.app365.com/bizweb/services/bizobjects/m56.Barcode/{id},同时post一个json工具

完好的恳求举例:

curl http://biz.app365.com/bizweb/services/bizobjects/m56.Barcode/
-H "Content-Type: application/json" -d @barcode.json
-H "Authorization: Basic YWRtaW46WW91ckFQSUtleUhlcmU="

效劳呼应

APP365 API依据恳求的后果,前往相应的HTTP形态代码。依据HTTP的规则,呼应依照下列形态码性子被分红几大类。堕落的呼应中也同时包括了一个错误音讯在呼应的body中,你可以依据这个音讯判别息争决题目。

2xx 挪用乐成

Code Definition Purpose
200 OK For successful GET/PUT requests.
201 Created For a successful POST request.
202 Accepted For a request that resulted in a scheduled task being created to perform the actual request.
204
No Content
For a successful request that produced no response (such as DELETE requests).

3xx 重定向

Code Definition Purpose
301 Moved Permanently When the API routes have changed (unlikely) or if the incoming request is not secure (http) then it will be redirect to the secure (https) version.
302
Found
When the resource was found at a different location. When a request to a deprecated version of the API is received, a 302 Found response will be issued to the current API version.
304
Not Modified
If an If-Modified-Since header is sent in the request and the resource has not been modified since the specified date, then this response will be sent. NB. See resource specific pages for support for the If-Modified-Since header.

4xx 客户端堕落

Code Definition Purpose
400
Bad Request
Issued when a malformed request was sent. Such as due to invalid syntax or missing required data.
401
Unauthorized
This response is sent when either the clients credentials are not provided or are incorrect.
403
Forbidden
When the user doesn't have permission to perform a specific operation on a resource (eg. edit a product). Permissions can be set through the store control panel.
404 Not Found When a particular resource doesn't exist or couldn't be found.
405
Method Not Allowed
The resource was found, but doesn't support the request method. Issued when either a specific method isn't yet implemented on a resource, or the resource doesn't support the method at all (eg. PUT on /orders is invalid, but PUT on /orders/{id} is valid).
406
Not Acceptable
When the client specifies a response content type in the Accept header that is not supported.
409 Conflict A change requested by the client is being rejected due to a condition imposed by the server. The exact reasons response for this will vary from one resource to the next. Examples may include attempting to delete a Category which would result in Products being orphaned. Additional information about the conflict and how to resolve it may be available in the details section of the response.
413
Request Entity Too Large
When the client requests too many objects. eg. the limit parameter was above the maximum allowed.
415
Unsupported Media Type
When the client specifies a content type in the Content-Type header that is not supported by the API.

5xx 效劳端堕落

Code Definition Purpose
500 Internal Server Error When an error has occurred within the API.
501 Not Implemented When a request method is sent that is not supported by the API (eg. TRACE, PATCH).
503
Service Unavailable
When the store is marked as "Down for Maintenance" or the store is being upgraded to a new version.
507
Insufficient Storage
When the store has reached a limitation for the resource according to their BigCommerce plan (eg 500 product limit).
509
Bandwidth Limit Exceeded
When the requests-per-hour limitations for the API have been reached.