/*1).請求地址:
"http://192.168.31.100:8069/zimo_rfids/pirfids_tags.api"
2).調用方式: HTTP post
3).接口描述:
接口描述詳情
頭部信息: Content-Type :application/json
4).請求參數:(示例參考)
{
"params": {
"tag_value": "mark_reset_count",
"reader_value": "ZMPIDCA6323F8EDD",
"value": " ",
"time": "2020-03-20 02:11:11"
} }
*/
n_httpresponse httpResponse
n_json json,jsonParm,jsonResult
n_httpClient httpClient
String ls_tt1,ls_tt2
String ls_where
json = Create n_json
jsonParm = Create n_json
httpClient = Create n_httpClient
//構建JSON數據包
//該數據包字符串化為:
//'{"params":{"tag_value": "mark_reset_count","reader_value": "ZMPIDCA6323F8EDD","value": " ","time": "2020-03-20 02:11:11"}}'
jsonParm.SetItem('tag_value','mark_reset_count')
jsonParm.SetItem('reader_value','ZMPIDCA6323F8EDD')
jsonParm.SetItem('value','')
jsonParm.SetItem('time','2020-03-20 02:11:11')
json.SetItem("params",jsonParm)
//發送請求並接收響應數據
//*發送JSON對象時默認Content-Type為application/json; charset=utf-8,你也可以手動指定為其它的
httpResponse = httpClient.Request(Enums.HTTP_METHOD_POST,"http://192.168.31.100:8069/zimo_rfids/pirfids_tags.api",json ) //
//顯示響應結果
if httpResponse.IsValid() then
ls_tt1 = "Headers:~r~n" + httpResponse.GetHeaders() + "~r~nResponse:~r~n" + httpResponse.GetDataString()
else
ls_tt2 = "Error:" + String(httpResponse.GetError()) + "~r~nError Info:~r~n" + httpResponse.GetErrorInfo()
end if
//獲取JSON數據(自動解析為JSON對象)
jsonResult = httpResponse.GetDataJSON()
//取響應數據的sign節點值
MessageBox("result",jsonResult.GetItemString("result"))
MessageBox("result2",jsonResult.GetItemString("jsonrpc"))
Destroy json
Destroy jsonParm