我需要帮助格式化REST JSON API的GET请求。首先,我必须承认我是Web应用程序的新手,这是我的问题。我有一个应用程序,它为我的HVAC恒温器中的参数公开了一个JSON API,我想将数据导入我的家庭自动化应用程序。家庭自动化应用程序提供了一个Web套接字接口,但我必须手动发送GET请求并解析结果。我看不到任何关于如何在直接文本中手动构造请求的示例。以下是API文档:
JSON API
Infinitive exposes a JSON API to retrieve and manipulate thermostat parameters.
GET /api/zone/1/config
{
"currentTemp": 70,
"currentHumidity": 50,
"outdoorTemp": 50,
"mode": "auto",
"fanMode": "auto",
"hold": true,
"heatSetpoint": 68,
"coolSetpoint": 74
}
我的获取请求:
GET /api/zone/1/config HTTP/1.1
Host: 172.16.16.43:8080
Content-Type: application/json
Accept: application/json
回复是:
HTTP:/1.1 200 OK
Content-Type: application/json; charset=UTF-8
Date: Sat, 07 Jan 2017 05:27:33 GMT
Content-Length: 5
true
所以我想我错过了我想要的参数但我在哪里/如何定义?
非常感谢