REST API Method Description

<< Click to Display Table of Contents >>

Current:  Advanced Analytics > WEB Service 

REST API Method Description

Previous pageReturn to chapter overviewNext page

In the process of using REST API, you need to understand the format of the request and response. The following points supplement the functions of this interface.

 

1. Update the data of the REST request node

Request address

http://ip:port/bi/rest/v1/experiment/node

Note:

This url is the address automatically generated in the service configuration after the experiment is created, and the format is uniform. The experiment is called through the parameter setting.

Request message

Request parameter

QueryParam为节点的apiKey,BodyParam为需要更新的数据。必填。

parametric description

apiKey is a string that is automatically generated when a node is created to identify the current node; BodyParam is the data sent from the client to the server to update the node specified by apiKey. For the data format, see the Body format description in 2. The current version supports Byte, Short, Integer, Long, Float, Double, Boolean, Character, String, Date, Time and Timestamp, a total of 12 data formats.

Sample

function updateInputNodeData () {

$.post("http://" + ip + ":" + port + "/" + project + "/rest/v1/experiment/node?apiKey=xxx",

  {},

  function(result) {

     writeJson(result);

  });

}

Response message

Response result

 

1)Service not started

{

   "success": false,

   "code": 20002,

   "message": "Service not started"

}

2)Interface responds normally

{

 "msgId":"4a32a2a259f44093bdad6d13dfca1834",

 "success":true,

 "code":20000,

 "message":"Success",

 "content":[

         {

                 "fieldName":"A",

                 "fieldType":"Byte",

                 "fieldData":[

                         2

                 ]

         }

 ]

}

Result description

The response result information is in json format.

1) Success indicates the response status, true indicates that the parameter is legal and the business process is processed normally, otherwise, it returns false;

2) code represents the return status code, different values represent different return statuses, see Appendix 1 for the description of the response message code;

3) message is the result information of the interface operation, it will display "success" when it succeeds, and display error information when it fails;

4) content is the data returned by the interface.

2. The format of the requested body

The Body passed when the user calls the interface through a POST request needs to meet the json format, as follows, where fieldName is the name of the column passed,

fieldType is the data type, and fieldData is the data.

The current version supports Byte, Short, Integer, Long, Float, Double, Boolean, Character, String, Date, Time and Timestamp, a total of 12 data formats.

format of the requested body

{

 "fieldList": [{

         "fieldName": "A",

         "fieldType": "Byte",

         "fieldData": [2]

 }, {

         "fieldName": "B",

         "fieldType": "Short",

         "fieldData": [4, 5]

 }, {

         "fieldName": "C",

         "fieldType": "Integer",

         "fieldData": [6, 7, 8]

 }, {

         "fieldName": "D",

         "fieldType": "Long",

         "fieldData": [9, 10, 11, 12]

 }, {

         "fieldName": "E",

         "fieldType": "Float",

         "fieldData": [13.01, 14.02, 15.03, 16.04]

 }, {

         "fieldName": "F",

         "fieldType": "Double",

         "fieldData": [17.04, 18.05, 19.06, 20.07, 21.08]

 }, {

         "fieldName": "G",

         "fieldType": "Boolean",

         "fieldData": [true, false, true, false, true, false]

 }, {

         "fieldName": "H",

         "fieldType": "String",

         "fieldData": ["a", "b", "c", "d", "e", "f", "g"]

 }]

}

 

The above parameters can be displayed in the product by defining the test code of the service configuration, and after the test is saved, connected to the data set view.

As shown below:

REST015

REST016

REST017

3. Response message code description

code = 20000

Indicates successful operation

code = 20001

Indicates that the license is illegal

code = 20002

Indicates that the service is not started

code = 20003

Indicates that the request parameter is wrong

code = 20004

Indicates service is interrupted

code = 20005

Indicates an unknown error