Summary:

  • Add device

API Version:

Version Developer Date Revised
2.0.0 lenny 2023-04-07 -

Request URL:

Request Method:

  • POST

Request Header:

Parameter Required Type Description
Content-Type Yes string Request type: application/json

Request Parameters:

Parameter Required Type Description
FTokenID Yes string Token ID
FAction Yes string Method name (AddAdminAssetBatch)
FAgentGUID Yes string Company unique identifier
FT_AdminAssetList Yes Object [{“FGUID”: device unique identifier,”FVehicleGUID”: vehicle unique identifier (not passing means unbinding),”FAssetID”: device ID,”FAssetTypeID”: device type,”FSIMNumber”: SIM card number,”FIMEI”: IMEI number,”FCustomerID”: device number,”FDescription”: description,”FAgentGUID”: company unique identifier},{“FGUID”: device unique identifier,”FVehicleGUID”: vehicle unique identifier (not passing means unbinding),”FAssetID”: device ID,”FAssetTypeID”: device type,”FSIMNumber”: SIM card number,”FIMEI”: IMEI number,”FCustomerID”: device number,”FDescription”: description,”FAgentGUID”: company unique identifier}]

Response Example:

When it returns correctly:

{
    "Result": 200,
    "Message": "check token success",
    "FObject": []
}

When it returns an error:

{
    "Result": 102,
    "Message": "Action is error",
    "FObject": []
}

Explanation of response parameters:

Parameter Name Type Explanation

Note:

  • More returned error codes are as follows:
  • 104: Token error or expired
  • 105: System exception
  • 102: Request parameter error
  • 106: There is an empty device number.
  • 107: There is a device ID that already exists.
  • 108: A vehicle has been bound to the device.
  • 109: There is an error in the device type.

Request Example:

Java:

String result = "";
// Request URL
String url = "http://cloud.assetscontrols.com:8092/OpenApi/Admin";  
// Request Body, JSON format, it's recommended to use an object to pass the parameters
String body = "{FAction:\"UpdateAdminAsset\",FTokenID:\"3acef045-d302-4032-b40a-d9ee6c1519cd\",FAgentGUID:\"3acef045-d302-4032-b40a-d9ee6c1519cd\",FT_AdminAssetList:\"[{"FGUID":"5baf6ccb-478e-4a13-91a6-6805ef93b7a7","FVehicleGUID":"9b32070e-6cf5-4995-8c60-4d250e6256f8","FAssetID":"645342344","FAssetTypeID":701,"FSIMNumber":"","FIMEI":"","FCustomerID":"","FDescription":"","FAgentGUID":"661e7209-c77e-4a54-afb8-6d956f962bdf"},{"FGUID":"5baf6ccb-478e-4a13-91a6-6805ef93b7a7","FVehicleGUID":"9b32070e-6cf5-4995-8c60-4d250e6256f8","FAssetID":"645342344","FAssetTypeID":701,"FSIMNumber":"","FIMEI":"","FCustomerID":"","FDescription":"","FAgentGUID":"661e7209-c77e-4a54-afb8-6d956f962bdf"}]";  
URL realUrl = new URL(url);
// Set common attributes for request
URLConnection conn = realUrl.openConnection(); 
conn.setRequestProperty("accept", "*/*");
conn.setRequestProperty("connection", "keep-Alive");
conn.setRequestProperty("Content-Type", "application/json");
conn.setRequestProperty("user-agent", "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1;SV1)");
conn.setRequestProperty("method", "post");
// Send POST request, must set the following two lines
conn.setDoOutput(true);
conn.setDoInput(true);
PrintWriter pw = new PrintWriter(conn.getOutputStream());
// Send request parameters
pw.print(body);
// flush the output stream buffer  
pw.flush();   
// Define BufferedReader to read the URL response
BufferedReader bufReader = new BufferedReader(new InputStreamReader(conn.getInputStream()));  
// Read URL response using BufferedReader input stream
String line;
while ((line = bufReader.readLine()) != null) {
     result += line;        
 }
// The response is a JSON string
return result;

C#:

// Request path
string url = "http://cloud.assetscontrols.com:8092/OpenApi/Admin";  
// Request parameter, in JSON format. It is recommended to pass the object as a parameter.
string body = "{\"FAction\":\"UpdateAdminAsset\",\"FTokenID\":\"3acef045-d302-4032-b40a-d9ee6c1519cd\",\"FAgentGUID\":\"3acef045-d302-4032-b40a-d9ee6c1519cd\",\"FT_AdminAssetList\":[{\"FGUID\":\"5baf6ccb-478e-4a13-91a6-6805ef93b7a7\",\"FVehicleGUID\":\"9b32070e-6cf5-4995-8c60-4d250e6256f8\",\"FAssetID\":\"645342344\",\"FAssetTypeID\":701,\"FSIMNumber\":\"\",\"FIMEI\":\"\",\"FCustomerID\":\"\",\"FDescription\":\"\",\"FAgentGUID\":\"661e7209-c77e-4a54-afb8-6d956f962bdf\"},{\"FGUID\":\"5baf6ccb-478e-4a13-91a6-6805ef93b7a7\",\"FVehicleGUID\":\"9b32070e-6cf5-4995-8c60-4d250e6256f8\",\"FAssetID\":\"645342344\",\"FAssetTypeID\":701,\"FSIMNumber\":\"\",\"FIMEI\":\"\",\"FCustomerID\":\"\",\"FDescription\":\"\",\"FAgentGUID\":\"661e7209-c77e-4a54-afb8-6d956f962bdf\"}]}";
Encoding encoding = Encoding.UTF8;
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url);
// Set general request properties
request.Method = "POST";
request.Accept = "*/*";
request.ContentType = "application/json";
request.UserAgent = "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1)";
byte[] buffer = encoding.GetBytes(body);
request.ContentLength = buffer.Length;
request.GetRequestStream().Write(buffer, 0, buffer.Length);
HttpWebResponse response = (HttpWebResponse)request.GetResponse();
using (StreamReader reader = new StreamReader(response.GetResponseStream(), Encoding.UTF8))
{
    // The returned value is a JSON string
    return reader.ReadToEnd();
}

Python:

import json
from urllib import parse, request

url = 'http://cloud.assetscontrols.com:8092/OpenApi/Admin'
data = {
    'FAction': 'UpdateAdminAsset',
    'FTokenID': '3acef045-d302-4032-b40a-d9ee6c1519cd',
    'FAgentGUID': '3acef045-d302-4032-b40a-d9ee6c1519cd',
    'FT_AdminAssetList': [{
        "FGUID": "5baf6ccb-478e-4a13-91a6-6805ef93b7a7",
        "FVehicleGUID": "9b32070e-6cf5-4995-8c60-4d250e6256f8",
        "FAssetID": "645342344",
        "FAssetTypeID": 701,
        "FSIMNumber": "",
        "FIMEI": "",
        "FCustomerID": "",
        "FDescription": "",
        "FAgentGUID": "661e7209-c77e-4a54-afb8-6d956f962bdf"
    }, {
        "FGUID": "5baf6ccb-478e-4a13-91a6-6805ef93b7a7",
        "FVehicleGUID": "9b32070e-6cf5-4995-8c60-4d250e6256f8",
        "FAssetID": "645342344",
        "FAssetTypeID": 701,
        "FSIMNumber": "",
        "FIMEI": "",
        "FCustomerID": "",
        "FDescription": "",
        "FAgentGUID": "661e7209-c77e-4a54-afb8-6d956f962bdf"
    }]
}
# Convert data to JSON format
data = json.dumps(data).encode('utf-8')
headers = {
    'User-Agent': r'Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) '
                  r'Chrome/45.0.2454.85 Safari/537.36 115Browser/6.'
}
req = request.Request(url=url, data=data, headers=headers)
with request.urlopen(req) as response:
    res = response.read().decode('utf-8')
    print(res)
文档更新时间: 2023-12-01 10:14   作者:Jeson