Brief Description:
- Adding fences in bulk
API Version:
Version | Author | Date Created | Date Updated |
---|---|---|---|
1.0.0 | lenny | 2022-09-22 | 2020-09-22 |
Request URL:
- http://icloud.assetscontrols.com:8092/OpenApi/Admin
- https://icloud.assetscontrols.com:3443/OpenApi/Admin
Method:
- POST
Request Headers:
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 (AddGISFenceBatch) |
FAgentGUID | Yes | string | Company unique identifier |
FT_GISFenceList | Yes | List<MT_GISFence> | Fence info. list |
MT_GISFence Object Description:
Parameter | Required | Type | Description |
---|---|---|---|
FName | Yes | string | Fence name |
FFenceTypeName | Yes | string | Fence Group name |
FNumber | No | string | FenceID |
FRemark | No | string | Fence remark |
FArea | No | double | Area |
FFormType | No | int | Fence type(1:Polygon;2:Round) |
FFenceTypeGUID | No | string | Fence group unique identifier |
FPath | No | string | Fence latitude and longitude collection |
FRadius | No | double | Radius |
FCenterLon | No | double | Center point longitude |
FCenterLat | No | double | Center point latitude |
FAddress | No | string | Address |
Response Example:
Successful Response:
{
"Result": 200,
"Message":"success",
"FObject": []
}
Error Response:
//It means that the object passed in is empty, and the data format should be incorrect.
{
"Result": 102,
"Message": "FT_GISFenceList is null",
"FObject": []
}
//Indicates an exception error report
{
"Result": 105,
"Message": "fail",
"FObject": []
}
//Indicates that the incoming fence name is empty and an error is reported.
{
"Result": 106,
"Message": "",
"FObject": []
}
//Indicates that the incoming fence group name is empty and an error is reported.
{
"Result": 107,
"Message": "",
"FObject": []
}
//Indicates that the incoming fence information is duplicated
{
"Result": 108,
"Message": "Duplicate fence name",
"FObject": []
}
Remark:
- More return error codes are as follows:
- 102: Request parameter error
- 104: token expired
- 105: Indicates an exception error.
- 106: Indicates that the incoming fence name is empty
- 107: Indicates that the name of the incoming fence group is empty
- 108: Indicates that the incoming fence information is duplicated
Request Example:
Java:
String result = "";
// Request URL
String url = "http://cloud.assetscontrols.com:8092/OpenApi/Admin";
// Request parameters, in JSON format, recommend to use an object to pass in
String body = "{
\"FAction\": \"AddGISFenceBatch\",
\"FAgentGUID\": \"c4b7730e-f74b-4dee-833b-0128bf5dd7f4\",
\"FT_GISFenceList\": [
{
\"FName\": \"Myfence1\",
\"FFenceTypeName\": \"Myfencetype1\"
},
{
\"FName\": \"Myfence2\",
\"FFenceTypeName\": \"Myfencetype2\"
}
],
\"FTokenID\": \"ec51d691-d9a7-4f74-95a8-1856be2ae745\",
\"FTimeDifferent\": 28800,
\"FLanguage\": \"1\"
}";
URL realUrl = new URL(url);
// Set generic properties of the 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");
// Must set the following two lines when sending a POST request
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 input stream to read the URL response
BufferedReader bufReader = new BufferedReader(new InputStreamReader(conn.getInputStream()));
// Define BufferedReader input stream to read the URL response
String line;
while ((line = bufReader.readLine()) != null) {
result += line;
}
// The returned value is in JSON format
return result;
C#:
// Request URL
string url = "http://cloud.assetscontrols.com:8092/OpenApi/Admin";
// Request parameters, in JSON format, recommend to use an object to pass in
string body = "{
\"FAction\": \"AddGISFenceBatch\",
\"FAgentGUID\": \"c4b7730e-f74b-4dee-833b-0128bf5dd7f4\",
\"FT_GISFenceList\": [
{
\"FName\": \"Myfence1\",
\"FFenceTypeName\": \"Myfencetype1\"
},
{
\"FName\": \"Myfence2\",
\"FFenceTypeName\": \"Myfencetype2\"
}
],
\"FTokenID\": \"ec51d691-d9a7-4f74-95a8-1856be2ae745\",
\"FTimeDifferent\": 28800,
\"FLanguage\": \"1\"
}";
Encoding encoding = Encoding.UTF8;
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url);
// Request method: post / get
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 in JSON format
return reader.ReadToEnd();
}
Python:
url = 'http://cloud.assetscontrols.com:8092/OpenApi/Admin'
data = {
'FAction': 'AddGISFenceBatch',
'FAgentGUID': 'c4b7730e-f74b-4dee-833b-0128bf5dd7f4',
'FT_GISFenceList': '[
{
\"FName\": \"Myfence1\",
\"FFenceTypeName\": \"Myfencetype1\"
},
{
\"FName\": \"Myfence2\",
\"FFenceTypeName\": \"Myfencetype2\"
}
]',
'FTokenID': 'ec51d691-d9a7-4f74-95a8-1856be2ae745',
'FTimeDifferent': 28800,
'FLanguage': '1'
}
data = parse.urlencode(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.0.3',
'Connection': 'keep-alive'
}
req = request.Request(url, headers=headers, data=data)
page = request.urlopen(req).read()
page = page.decode('utf-8')
# json_array = json.loads(page)
return page;
文档更新时间: 2023-12-12 17:59 作者:刘家帅